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?
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 /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"
Icon file: cmd (((or wciconex.dll or WCMICONS.DLL)))
Erst wenn der letzte Baum gefällt oder die letzte Biene verendet ist, werden die Leute verstehen warum Umweltschutz wichtig ist.
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
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).
* 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
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.
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.* "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).