Create New TXT, grabbing name from selected file

Hi,

FYI, I'm not good at programming! BUT somehow created this button... lol :wink:

@nofilenamequoting @runonce:@set filename={dlgstringS|Enter name of file|{file$|noext}} FileType NEW=.txt NEWNAME="{$filename}"
I Select a file. Click the button, it opens a dialog box with the same name as the currently selected file. I change the name slightly and hit OK/Enter. It creates the file and names it perfectly, but leaves the file in the Lister as if I want to rename it.

The problem I can't figure out is. How can I create the file and not have it go to the "rename" state in the Lister? Better yet, How can it just create the file and open it straight a-way?

On a side project. Can the button work so that if no file is selected, the same dialog opens, but empty, and I can just type in a name (currently it doesn't)? If not, I can just create an three way button to do the 2 different commands.

Thanks!

Changes:

[ul][li]You don't need @runonce with @set.[/li]
[li]To make {file$} optional, use {file} instead.[/li]
[li]Put "norename:" before the NEWNAME if you don't want the inline rename stage to happen.[/li]
[li]Just pass the filename to your text editor if you want to open the file afterwards.[/li][/ul]

@nofilenamequoting @set filename={dlgstringS|Enter name of file|{file|noext}} Filetype NEW=.txt NEWNAME="norename:{$filename}" "C:\Program Files (x86)\TextPad 5\TextPad.exe" "{sourcepath}{$filename}.txt"

Note that many text editors will create a new file automatically if given a filename that doesn't already exist, so you can often reduce the command to:

@nofilenamequoting "C:\Program Files (x86)\TextPad 5\TextPad.exe" "{sourcepath}{dlgstringS|Enter name of file|{file|noext}}.txt"

Thank You, Thank You, Thank You Leo! Works Perfectly (of course)! :smiley:

Thanks for pointing out my mistakes too. It's the only way I'll learn :slight_smile: