Creating Notepad file

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
Sir_SiLvA
Power Member
Power Member
Posts: 3278
Joined: 2003-05-06, 11:46 UTC

Post by *Sir_SiLvA »

yes cause u can also create other files this way.
Hoecker sie sind raus!
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

As Sir_SiLvA mentioned, Shift+F4 allows editing ANY file with specified name, not only TXT files. If this file doesn't exist, TC creates it and opens for editing. Therefore this function may be used for creating of text files. However it may work wrong if you try to create e.g. DOC file (DOC files can't be empty, they are created from templates).
darkside999
Junior Member
Junior Member
Posts: 14
Joined: 2012-12-02, 21:58 UTC

Post by *darkside999 »

I have a similar question.
I want create "File_ID.txt" empty file and open it with only a button.

If I use Shift+F4 I have to write the filename but I'am looking for a quicker mode.

Any ideas?

Thanks
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Just use button with command like:

Code: Select all

Command: Notepad.exe
Parameters: "%P\File_ID.txt"
(feel free to use any text editor you like)
darkside999
Junior Member
Junior Member
Posts: 14
Joined: 2012-12-02, 21:58 UTC

Post by *darkside999 »

OK, thanks. It works but isn't still perfect.

When launch notepad a popup ask if I want create a new file and I click "yes". I would like to eliminate this click.

I was thinking to a bat like:

copy C:\totalcmd\file_id.txt (to active panel but I don't know how)

cd (active panel, but I don't know how)

notepad.exe file_id.txt (or notepad.exe Activepanel/file_id.txt


any ideas?

Thanks
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

You can use following batch file:

Code: Select all

@echo off
copy nul file_id.txt
start "" "Notepad.exe" file_id.txt
Just clear start path field in the button to make it working with your current panel's path.
Also same may be done w/o batch file with instant commands:

Code: Select all

Command: cmd.exe
Parameters: /c "copy nul "%P\file_id.txt" & start "" "Notepad.exe" "%P\file_id.txt""
Minimized: Yes
User avatar
Stefan2
Power Member
Power Member
Posts: 4133
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

Me think there is a IF NOT EXIST mising ;-)





 
User avatar
Stefan2
Power Member
Power Member
Posts: 4133
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Powershell create new file or open existing file

Post by *Stefan2 »

With POWERSHELL

If not exist File_ID.txt, create it. After that decision, open the file in notepad.exe:

Code: Select all

$file=$pwd.path+"\File_ID.txt"; if(!$file.Exist){new-item -path $file -type "file"}; notepad $file;

TC Button:
CMD: powershell
Para: the code
Path:
Icon: powershell
[X] run minimized



Note:
for use with TC I had to escape the quote chars " in PS as """


Change 'notepad' with your ' "path\to\editor" '.


- - -

Create on every execution a file with a new ID:

File_ID1.txt
File_ID2.txt
File_ID3.txt

Code: Select all

$id=1; $file=$pwd.path+"""\File_ID$id.txt"""; while(test-path $file){$id++;$file=$pwd.path+"""\File_ID$id.txt"""}new-item -path $file -type """file"""; notepad $file
Or formate to pad to length of three digits:

File_ID001.txt
File_ID002.txt
File_ID003.txt
File_ID004.txt

Code: Select all

$id=1; $file=$pwd.path+"""\File_ID{0:D3}.txt""" -f $id; while(test-path $file){$id++;$file=$pwd.path+"""\File_ID{0:D3}.txt""" -f $id}new-item -path $file -type """file"""; notepad $file


.
darkside999
Junior Member
Junior Member
Posts: 14
Joined: 2012-12-02, 21:58 UTC

Post by *darkside999 »

MVV wrote: Also same may be done w/o batch file with instant commands:

Code: Select all

Command: cmd.exe
Parameters: /c "copy nul "%P\file_id.txt" & start "" "Notepad.exe" "%P\file_id.txt""
Minimized: Yes
Hi. It's working. Thank you.

I have made a modify, just in case the file "File_Id.txt" is present:

Code: Select all

Command: cmd.exe
Parameters: /c "copy nul "%P\file_id.txt"/-Y & start "" "notepad.exe" "%P\file_id.txt""
Minimized: Yes
That way if the file is present will come out a warning. Typing [y]es the file will be overwritten. Typing [n]o the existing file will be opened in Notepad

Thanks again
Post Reply