- how to handle duplicates?
- how to get the computed new name?
-----------------------------------------------------------------------
I am working on an "create new file from <curitem>"
and tried to code an algo like "#164 Copy Here with Suffix Number" at position (3a)
I can use #164 in an script..... but
Question:
how can i select this fresh created file to open it?
(i mean simple!, no big workarounds like select by creating time,... on the other hand... maybe an idea, will try...)
Or could #164 calculate the new, unique file name for me and provide it me for re-use?
EDIT: see next posts below for an corrected version.
Code: Select all
// Create an new TXT-file with base-name of current selected item:
// (1) if cursor is over an file or folder use this current name (base only, without extension)
// else use "New File" as name:
$base = (<curbase>)? <curbase>: "New file from <date yyyy-mm-dd>";
// (2) prompt user to correct the name:
$base = Input('Create new file',New file name based on: $base, $base.".txt");
// (3) if file already exists, add an trailing digit:
IF exists($base)=1 {
// (3a) Copy Here with Suffix Number (my own code is removed to simplify, and because not really working)
#164;
// (4) open notepad to edit this new file:
Run Notepad $new_#164_file;
}else{
// (3b) create the new file in current dir:
new $base, file;
// (4) open notepad to edit this new file:
Run Notepad $base;
}
XYplorer Beta Club