Button for creating subfolders

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
Mihai-Edward
Junior Member
Junior Member
Posts: 11
Joined: 2019-04-21, 18:38 UTC

Button for creating subfolders

Post by *Mihai-Edward »

Hello everyone!

I'm trying to create a button that creates a subfolder named "TEMP" in some specific folders that i have selected. In the other words, i want to select some folders, then push this button to create a subfolder named TEMP in each selected folders. I tried to figure it out how to use parameters listed in TC Help but with no success. I was hoping that someone experienced to help me with some good parameters for what i need.

I tried to use following settings:

Command: cmd /c
Parameters: md %P%S\TEMP

But with this settings it only creates a subfolder TEMP in the last of selected folders.
Can anyone help me with this, please?
User avatar
Stefan2
Power Member
Power Member
Posts: 4132
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Button for creating subfolders

Post by *Stefan2 »

Hi and welcome!

In button-dialog press F1 and read:
%L, %l, %F, %f, %D, %d, %WL, %WF, %UL, %UF
create a list file in the TEMP directory with the names of the selected files and directories...
%F = Long file names without path, e.g. Long name.exe


So the temp file behind e.g. parameter "%F" contains the name of all selected folders.
Next use a FOR command (or call a batch) to do something for each line/folder of file %F.


For example:
for /f "usebackq delims=" %%s in (`type "%F"`) do @echo Do something with "%%s"



So create a button
Command: cmd /k
Parameter: for /f "usebackq delims=" %%s in (`type "%F"`) do @md "%%s\TEMP"
Start path:
Icon file: cmd (((or wciconex.dll or WCMICONS.DLL)))
Tool tip:




HTH?
 
Mihai-Edward
Junior Member
Junior Member
Posts: 11
Joined: 2019-04-21, 18:38 UTC

Re: Button for creating subfolders

Post by *Mihai-Edward »

Thank you, Stefan! I have to study more about this. Button created and working but leaves behind an open window of command prompt. Is there any way for it to close itself?
Mihai-Edward
Junior Member
Junior Member
Posts: 11
Joined: 2019-04-21, 18:38 UTC

Re: Button for creating subfolders

Post by *Mihai-Edward »

Ah, i figure it out! "cmd /c" instead of "cmd /k" fix it. Thank you!
User avatar
Dalai
Power Member
Power Member
Posts: 9364
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Button for creating subfolders

Post by *Dalai »

2Stefan2
Be careful with %F. This could cause creating directories elsewhere when the script is called from a different working directory, e.g. when using branch view or from search results. Also, %L only creates a list file with ANSI encoding (in the current codepage), but you call CMD which by default uses ASCII, breaking characters not part of ASCII in the process, thus creating directories elsewhere. Creating the list file in UTF-16 and calling CMD with /U fixes this.

And lastly, no need to use "usebackq" here. Just use normal single quotes instead of backticks.

All in all, it's better to use something like this:

Code: Select all

TOTALCMD#BAR#DATA
cmd /u /k
for /f "delims=" %%s in ('type "%WL"') do @echo "%%~sTEMP"
cmd.exe



-1
Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Mihai-Edward
Junior Member
Junior Member
Posts: 11
Joined: 2019-04-21, 18:38 UTC

Re: Button for creating subfolders

Post by *Mihai-Edward »

Thank you for your answer, Dalai!
I will take a close look at this. I'm kind of newbie in parameters.
User avatar
Usher
Power Member
Power Member
Posts: 1675
Joined: 2011-03-11, 10:11 UTC

Re: Button for creating subfolders

Post by *Usher »

Dalai wrote: 2019-04-21, 20:42 UTCAlso, %L only creates a list file with ANSI encoding (in the current codepage), but you call CMD which by default uses ASCII
Wrong names. To be more clear, you should use either "Windows and DOS" or "ANSI and OEM" pairs of names for codepages set according to system locale (regional settings).
Note that:
* You can change codepage for both Windows and console separately. F.e. you can use Windows or Unicode UTF-8 codepage in console.
* In 64-bit Windows you should expect that console uses Windows codepage rather than DOS one.
* "ASCII" should be used only as a synonym for US-ASCII 7-bit charset, which is a basic subset of all 8-bit encodings (DOS, Windows and Unicode UTF-8). Other use is misleading.
Andrzej P. Wozniak
Polish subforum moderator
User avatar
Dalai
Power Member
Power Member
Posts: 9364
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Button for creating subfolders

Post by *Dalai »

Usher wrote: 2019-04-21, 23:02 UTC* In 64-bit Windows you should expect that console uses Windows codepage rather than DOS one.
But it doesn't, at least not when reading/writing text to/from files/pipes. I'm sure you know about the decade old issue that CMD doesn't show and use umlauts correctly that are written by TC with %L (i.e. the current ANSI codepage, e.g. 1252 or 1251). CMD would need to be switched from OEM (=Codepage 850 = Extended ASCII) to the current ANSI codepage to show and use them correctly (which is what one of my wrapper scripts does). But that doesn't solve anything for Unicode, i.e. two-byte, characters.
* "ASCII" should be used only as a synonym for US-ASCII 7-bit charset, which is a basic subset of all 8-bit encodings (DOS, Windows and Unicode UTF-8).
Yeah, well, that's pretty much what CMD does, unless you specify /A for ANSI or /U for Unicode (=UTF-16) - still talking about text files here. Funny thing is that /A didn't work for me in the tests I did previously. Probably some MS thing again I don't understand.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Post Reply