How to create list of folders from selected names

English support forum

Moderators: white, Hacker, petermad, Stefan2

User avatar
milo1012
Power Member
Power Member
Posts: 1158
Joined: 2012-02-02, 19:23 UTC

Post by *milo1012 »

2nsp
That's not what I wanted to express in my post, but that cmd.exe is able to parse and use an UTF-16 list file in a for loop losless (i.e. it won't recode the names), as long as you type that file with

Code: Select all

`type %1`
just as in the example that I linked.
In such case, you don't need to bother about making cmd.exe Unicode capable with switches or code pages in the first place, as long as the command chain does not invoke a recode.

But sure, it's probably a matter of interpretation, if cmd.exe really is Unicode capable by nature, or just in some special cases.
TC plugins: PCREsearch and RegXtract
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

I could not make the /U switch for %COMSPEC% work.

But this button seems to do it:

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C chcp 65001
&& %%COMSPEC%% /C for /F  "usebackq delims=" %%n in (`type %WF`) do if not exist "%T%%n" md "%T%%n"
wcmicons.dll,29
Create directories in target panel from selected source panel names

1
-1
I have to put a %%COMSPEC%% /C in the parameters line, otherwise the codepage change is not recognized in the for loop. It is the same if I run it in a batch file. the chcp and the for command has to be on different lines otherwise it does not work (can't do: chcp 65001 && for...)

I also have to do an if not exist "%T%%n" test before making each dir - otherwise the loop stops if %%n is a unicode name and the directory already exists.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I believe this code deserves an entry in TC's Wiki.
Please, instead of suggesting it, just add it yourself! You can log in to the wiki with the same user name and password as here in the forum.
Author of Total Commander
https://www.ghisler.com
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

Based on the code above I have made these buttons (will all be incorporated in the next release of my Extended Menus):

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
chcp 65001 && %%COMSPEC%% /C for /F "usebackq delims=" %%n in (`type %WF`) do if "%%~nn"=="" (if not exist "%T%%n" md "%T%%n") else if not exist "%T%%~nn" md "%T%%~nn"
wcmicons.dll,29
Make directories with same names as selected files in opposite panel

1
-1

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
chcp 65001 && %%COMSPEC%% /C for /F "usebackq delims=" %%n in (`type %WF`) do if not exist "%T%%n" md "%T%%n"
wcmicons.dll,29
Make directories with same name + extensions as selected files in opposite panel

1
-1

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
(if not exist "%T%O" md "%T%O") && chcp 65001 && %%COMSPEC%% /C for /F "usebackq delims=" %%n in (`type %WF`) do if not exist "%%n\*" copy "%%n" "%T%O\"
wcmicons.dll,62
Copy marked files to directory with name as file under cursor in opposite panel

1
-1

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
(if not exist "%T%O.%E" md "%T%O.%E") && chcp 65001 && %%COMSPEC%% /C for /F "usebackq delims=" %%n in (`type %WF`) do if not exist "%%n\*" copy "%%n" "%T%O.%E\"
wcmicons.dll,62
Copy marked files to directory with name + extension as file under cursor in opposite panel

1
-1

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
(if not exist "%T%O" md "%T%O") && chcp 65001 && %%COMSPEC%% /C for /F "usebackq delims=" %%n in (`type %WF`) do if not exist "%%n\*" move "%%n" "%T%O\"
wcmicons.dll,63
Move marked files to directory with name as file under cursor in opposite panel

1
-1

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
(if not exist "%T%O.%E" md "%T%O.%E") && chcp 65001 && %%COMSPEC%% /C for /F "usebackq delims=" %%n in (`type %WF`) do if not exist "%%n\*" move "%%n" "%T%O.%E\"
wcmicons.dll,63
Move marked files to directory with name + extension as file under cursor in opposite panel

1
-1

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
chcp 65001 && %%COMSPEC%% /C for /F "usebackq delims=" %%n in (`type %WF`) do copy %N "%%n"
wcmicons.dll,62
Copy the content of file under cursor to marked files

1
-1
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Post Reply