Page 2 of 4

Re: Create multiple files at once

Posted: 2023-06-27, 11:37 UTC
by Hacker
Christian,
OK, then can we at least get the following?
Shift-F4, enter "|file1.txt|file2.txt", press Enter - to create those two files without opening them in an editor? Basically, a pipe prefix would instruct TC not to open the editor for the given (pipe-separated) files.

Roman

Re: Create multiple files at once

Posted: 2023-06-27, 12:21 UTC
by Sir_SiLvA
Hacker wrote: 2023-06-27, 11:37 UTC Christian,
OK, then can we at least get the following?
Shift-F4, enter "|file1.txt|file2.txt", press Enter - to create those two files without opening them in an editor? Basically, a pipe prefix would instruct TC not to open the editor for the given (pipe-separated) files.
Support ++
(imho "file1.txt|file2.txt" alone should instruct tc to create multiple files without opening them)

Re: Create multiple files at once

Posted: 2023-06-27, 23:39 UTC
by monarch-lfv
This does not cancel the suggestion in the topic, but it may come in handy, the script on VBS:

Code: Select all

' Creation of empty files separated by a sign '|'
' with the replacement of prohibited characters with "_" 
' and removal of spaces at the beginning and at the end  

' Parameters: %P
'======================================================================
On Error Resume Next
Dim FSO, Fn, Sym, i, F, f1
Set FSO = CreateObject("Scripting.FileSystemObject")
Fn=Inputbox("File names separated by a sign '|'", "Create files", "File 1.txt|File 2.ext | ""fil.?x*""")
Sym = "/\*?"
For Each F In Split(Fn, "|")
  F=Replace(F, """", "")
  For i = 1 To Len(Sym)
    F = Replace(F, Mid(Sym, i, 1), "_")
  Next
  Set f1 = FSO.CreateTextFile(WScript.Arguments(0) & Trim(F), False)
Next

Re: Create multiple files at once

Posted: 2023-06-28, 17:39 UTC
by Hacker
Sir_SiLvA,
imho "file1.txt|file2.txt" alone should instruct tc to create multiple files without opening them
file1.txt|file2.txt could simply open two editor windows with those files. I wanted to keep that reserved for such use in the future perhaps.

Christian,
Thank you very much for adding this in TC11b9! 8)
Any chance we could change the syntax to:

Code: Select all

|file1.txt|file2.txt
(with first symbol pipe) simply creates the two files, and

Code: Select all

file1.txt|file2.txt
(without first symbol pipe) creates the files and opens the editor for each of them (that would be a future suggestion, but the syntax would work).

TIA
Roman

Re: Create multiple files at once

Posted: 2023-06-28, 17:58 UTC
by Sir_SiLvA
Hacker wrote: 2023-06-28, 17:39 UTC I wanted to keep that reserved for such use in the future perhaps.
I prefer some consistency so that what works in the New Dir Dialog works the exact same in the New File Dialog ... 8)

@Chris: Thanks for adding this :!:

Re: Create multiple files at once

Posted: 2023-06-28, 18:41 UTC
by Hacker
Sir_SiLvA,
I prefer some consistency
Which in this case prevents the implementation of a useful feature. Perhaps you have some alternative implementation idea?

Roman

Re: Create multiple files at once

Posted: 2023-06-28, 18:56 UTC
by Sir_SiLvA
Hacker wrote: 2023-06-28, 18:41 UTC Which in this case prevents the implementation of a useful feature. Perhaps you have some alternative implementation idea?
Yes I would put your | at the end followed by a > to tell tc to start the created files
(1st check for internal associations ofc, 2nd if none are found let windows sort it out 8))
which would open the possibility to even do something crazy (which will hence never be implemted by Chris :))
like file1.txt|file1.jpg|file2.jpg|file2.txt|readme.rtf|>2-3(some jpg editor),5(some text writting app)
which would tell tc to 1st create file1.txt, file1.jpg, file2.jpg, file2.txt & readme.rtf and then run the jpgs with "some jpg editor".
My point is that by putting your pipe at the end you are open to do more usefull stuff without being incosistence
if you get my drift :?:

(I hope this translated at all into english and yes I am aware that a syntax with () and , is not the best choice as
both can be part of filename but it was just an example)

Re: Create multiple files at once

Posted: 2023-06-28, 19:47 UTC
by Hacker
Sir_SiLvA,
Well, I get your idea, but I am not sure if there is any non-text editor out there which can open an empty file and treat it as a valid one (jpg / bmp / rtf / html / docx / mp3 / etc.etc.).

Roman

Re: Create multiple files at once

Posted: 2023-06-28, 20:36 UTC
by Sir_SiLvA
Hacker wrote: 2023-06-28, 19:47 UTC Sir_SiLvA,
Well, I get your idea, but I am not sure if there is any non-text editor out there which can open an empty file and treat it as a valid one (jpg / bmp / rtf / html / docx / mp3 / etc.etc.).
I know :-/ but at least something like
file1.txt|file2.txt|file3.txt|file4.html|readme.rtf|>1-3(some_path\NoteTab.exe),4(some_path\notepad++.exe),5(wordpad.exe)
would work (with only 3 shellex calls instead of 5 :-)) :D

otherwise lets add at least |> for hackers suggestion :!:

Re: Create multiple files at once

Posted: 2023-06-28, 21:24 UTC
by Hacker
Sir_SiLvA,
file1.txt|file2.txt|file3.txt|file4.html|readme.rtf|>1-3(some_path\NoteTab.exe),4(some_path\notepad++.exe),5(wordpad.exe)
Is that a realistic scenario? Open five empty new text files in three different editors?
lets add at least |> for hackers suggestion
Thanks.

Roman

Re: Create multiple files at once

Posted: 2023-06-30, 09:49 UTC
by Fla$her
ghisler(Author) wrote: 2023-06-27, 10:59 UTC Unfortunately this would not work well together with parameter 1. Numeric parameters can be passed as LPARAM directly to the internal function, text parameters can't. It would break scripts calling cm_EditNewFile with parameter 1.
In this case, you can add cm_CreateNewFile in which multi-mode will be supported.

Re: Create multiple files at once

Posted: 2023-07-05, 16:02 UTC
by ghisler(Author)
In beta 10, I have added parameters to cm_Edit instead of cm_EditNewFile. It allows to just open, just create, or create and open files. It allows to open them either with the configured editor, or with an associated program (with or without internal associations). Please let me know what you think! The options are (from the help):

The following parameters can be passed to the function behind a slash:
C: Create files which do not already exit
T: Instead of creating an empty file, copy a template file to the new name. By default, the user's template directory will be used. The first file in it with the same extension will be copied to the new file. If no file is found, an empty file will be created
T="c:\path": Sames as T but use the specified template directory
N="name": The name(s) of the file(s) to be created
G: Go, create new files immediately (has no effect when not using C)
L: Launch type: L0=do not launch, L1=open with default editor, L2=open with associated program (including internal associations), L3=open with associated program (no internal associations)
V="verb": Combined with L2 or L3, set the verb to open the file, e.g. "open" or "edit". Leave out for default verb.

Re: Create multiple files at once

Posted: 2023-07-05, 19:41 UTC
by hi5
Typo: Create files which do not already exit -> exist

Re: Create multiple files at once

Posted: 2023-07-05, 21:02 UTC
by petermad
By default, the user's template directory will be used
Where will that typically be? I have 2 templates directories in my Windows user profile:
"%AppData%\Roaming\Microsoft\Templates"
"%AppData%\Roaming\Microsoft\Windows\Templates"

They are both empty - which of the two will TC use - if any?

EDIT: I figured out that TC uses "%AppData%\Roaming\Microsoft\Windows\Templates"

There is a bug when trying to use the parameters in the Command field of a button - see: https://ghisler.ch/board/viewtopic.php?t=79523

I suggest to change the help text a little:
N="name": The name(s) of the file(s) to be created
to
N="name": The name(s) of the file(s) to be created - separate multiple file names with the | character
Otherwise only people who has read this topic will know to use | between multiple file names.

Re: Create multiple files at once

Posted: 2023-07-06, 08:37 UTC
by ghisler(Author)
TC uses %$Templates%, you can go there via command line:
cd %$Templates%
Otherwise only people who has read this topic will know to use | between multiple file names.
Agreed, although it's not the only way, you can also use a counter as in the regular Shift+F4 dialog box.