New... textfile > How to auto-select it?

Hi,

Is is possible to auto-select a newly created file ? I mean Rightclick/New/Textfile. I would like this behaviour for other newly created files that way.

TIA!

I often create new zero byte text files called "ReadMeJohn.txt" because I know when I see such a file it'll have special notes for me about the folder it is in. Here is the code I use to create such text files (which are selected).

Select NONE FileType NEW=.txt NEWNAME="norename:ReadMeJohn" Select PATTERN="ReadMeJohn.txt"

Thanks for the "norename:" argument... :wink:
it will be interresting to have this on manual. :stuck_out_tongue:

Ah great !

But would it also be possible for no predefined new textfile-name ? So the Select PATTERN option adapts to the name you gave the new file ?

TIA! :wink:

You can do that like this:

@nofilenamequoting 
@set fn={dlgstringS|Enter new file name|ReadMe}
FileType NEW=.txt NEWNAME="norename:{$fn}"
Select PATTERN="{$fn}.txt"

Seems like a lot of trouble to go to just to avoid hitting space after using the usual New method, though. (Where you type the name inline.)

1 Like

Thanks a lot nudel, the problem is, as stated in the top post, I would like this to happen when I rightclick a lister and choose New/Textfile...

In other words, no code for a button but make DO do this automatically after creating a new file from the rightclick menu.

If you want to type the name of the file, what's wrong with just putting FileType NEW=.txt (by itself) on the right-click menu?

After clicking it you type the name, get a new text file and if you want it selected push space after pushing return.

Actually, I just tried it and it is selected automatically, but it isn't given the keyboard focus which I can see being annoying in some situations. The same is true for my button.

Well, it seem to work if a add DESELECTNOMATCH after your Select PATTERN="{$fn}.txt" line.

Now just getting it into the rightclick menu...

Customize - Context Menus - Lister Context.

Great!

Once again, thanks nudel ! :slight_smile:

Hi.

I'm a total noob and i was searching a solution made for other people to do it.

I tried the method of leo and works fine, but I would like to ask if it would be possible that the new txt document would be opened after rename her to write directly into them by any form.

With the method of leo, the txt is created and after rename I must to open it with double click to write into.

Sorry for my limited english.
Thx 'n greetz.

Assuming your text editor is like TextPad and will create files if they don't already exist, you can do that very easily:

"C:\Program Files\TextPad 5\TextPad.exe" "{RS|Enter new file name:|New Text File.txt}"

Works with Notepad, too:

"Notepad.exe" "{RS|Enter new file name:|New Text File.txt}"

How would i make the same with a RTF? Following:

"wordpad.exe" "{RS|Enter new file name:|New Text File.rtf}"

will cause a "new text file not found" error message. I guess replacing notepad with wordpad was not appropriate. It would be nice, that after clicking the button there should be a box waiting for the new file name, & appending the rtf extension automatically.

I guess WordPad doesn't let you do that. Instead, you could create an empty file and then run WordPad on it, using the copy FILE="nul"... method described in this thread:

[How to? New file without extension)

Automatically appending .rtf to whatever you type is as simple as putting .rtf in the command after the prompt for the filename.

@set name={dlgstringS|Enter File Name|.rtf} 
copy FILE="nul" AS="{$name}" HERE 
select {$name}

works very nicely from the context menu. thank you!
The ".rtf" portion is selected when creating a new RTF, so i only have to push pos1 & can give it a name. Is it even possible to have the .rtf unselected with the cursor already waiting in the right position?

(yeah, i know how lazy that sounds) :smiley:

Just put the .rtf outside of the dialog prompt. You also need to put quotes around the argument to the select command, else it won't work with spaces in the name.

Like so:

@set name={dlgstringS|Enter File Name|New Document}.rtf
copy FILE="nul" AS="{$name}" HERE
select "{$name}"

Didn't you want WordPad to open the file though?

@set name={dlgstringS|Enter File Name|New Document}.rtf
copy FILE="nul" AS="{$name}" HERE
WordPad.exe "{$name}"

That second one is exactly how i wanted it, thank you very much. I also have made a button doing basically the same, as described earlier in this thread, but from the context menu it´s even more handy.

Cool. :slight_smile:

(I'm really just posting this to make the "last post" thing valid again after deleting the duplicate post. :slight_smile:)