Filetype NEW=.txt NEWNAME "{file}.txt"
Is there a way to do something like 'noselect' when creating a new file? i.e. I create a new .txt file using:
@nofilenamequoting
Filetype NEW=.txt NEWNAME="{dlgstringS|Enter new .txt file name:|New Text Document}"
@confirm:Open for editing?
notepad2 "{sourcepath}{$newfile}"
Even though I have have either manually typed in a name, or allowed the default name to happen, the file gets created, and the stem is still highlighted and selected, waiting for the rename. So, I have to either press Enter, to click an empty space to exit the rename mode, and allow for the rest of the function to finish. It'd be nice to have it not enter rename mode after the file is created.
Even a sort of hacky, Sendkeys {ENTER} type of thing would work there, but I didn't notice anything in the dox for either.
Update:
Scratch that! Solved my own problem. (norename:)
From the FileType Command page in the manual:
this is what i wanted exactly
drop empty readme.txt file
cheers
FileType NEW .txt NEWNAME "norename:readme.txt"
Following the examples above, I created my own button to create an empty text file.
With three variants, using the name from the selected file, taking a name from the clipboard or a standard name.
The problem is that if I don't select any files I can't make any choices. The button don't work.
Is it possible to hide a choice if it doesn't meet the requirements? (i.e. if I do not select anything or there is no text in the clipboard)
Maybe you have some suggestions!
Thank you
@nofilenamequoting
@set tempname= {dlgchoose|Nome del File:|Selezione={file$|noext}+Clipboard={clip}+Nuovo Documento=Nuovo documento}
@set name {dlgstringS|Nome del File:|{$tempname}}
Filetype NEW=.txt NEWNAME="norename:{$name}"
EditPadPro8 "{sourcepath}{$newfile}"
Yes, but you would need to use scripting for that kind of conditional logic.
Use file
instead of file$
.
Same thing, if I change that and don't select the file, the button doesn't work ..
Actually I created a small dialog for creating a set of predefined filetypes (emtpy files with specific extensions). I use jscript for accomplishing this. If interested i can share this code.
With scripts I don't even know where to start, but if you can share it, I try to see if I can adapt it to my needs .
If you're running this from a toolbar button, the easiest thing to do would be to change the button into a menu, then put the individual commands you want as items within that. Doesn't require any script or dialogs at all then.
(Downside: It wouldn't tell you what was currently in the clipboard as part of the labels.)
Effectively, better than nothing...
Here is my button. Very old, might not be a good implementation but might help you.
New file.dcf (6.6 KB)
(Just updated the button, there was a small bug in it).
And this might be the interesting code snippet for you.
function CreateFile(path, fileName)
{
var fso = new ActiveXObject("Scripting.FilesystemObject");
var file = fso.CreateTextFile(path +"\\" + fileName, true);
file.Close();
}
Thanks, I'll do some tests