How to create list of folders from selected names

English support forum

Moderators: white, Hacker, petermad, Stefan2

Umbardacil
Junior Member
Junior Member
Posts: 3
Joined: 2017-06-20, 05:17 UTC

How to create list of folders from selected names

Post by *Umbardacil »

Hi guys!

I wonder if there already exists a button, which will create list of directiories in " target" panel from names (files or directories) which I mark on the "source" panel?
User avatar
Stefan2
Power Member
Power Member
Posts: 4133
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

Hi, such button can be created easily.


But what do you want?

"create list of directiories ... from names (files or directories) which I mark"

I do not understood completely.





 
Umbardacil
Junior Member
Junior Member
Posts: 3
Joined: 2017-06-20, 05:17 UTC

Post by *Umbardacil »

Stefan2 wrote:Hi, such button can be created easily.


But what do you want?

"create list of directiories ... from names (files or directories) which I mark"

I do not understood completely.
 
1. I mark (highlight red) positions on the source panel (regardless if it's file or directory)
2. Button makes directories on the target panel with names selected in step 1

Background: sometimes I need to create folders with names based on file name without extension.
User avatar
Stefan2
Power Member
Power Member
Posts: 4133
Joined: 2007-09-13, 22:20 UTC
Location: Europa

PowerShell: create folder from selected files in target pane

Post by *Stefan2 »

TC can provide a list of selected files and folders by using parameters like "%L" to create commands used as button or user command (and next keyboard shortcut).
(right click existent button / Change... / press F1 / close button / read help about params)

Note also the %T parameter to access the Target panel.






Next we can use a scripting tool like DOS Batch, PowerShell, VBScript or AutoHotkey or such to process each line (file) of that list.

Example:
Command: PowerShell -NoProfile -ExecutionPolicy RemoteSigned -NoExit
Parameters: Get-Content '%F' | ForEach{ $_ }
Icon: PowerShell





For your case
Command: PowerShell -NoProfile -ExecutionPolicy RemoteSigned -NoExit
Parameters: Get-Content '%F' | ForEach{ New-Item -Type "directory" -Path ("""%T""" + """\$_""") -WhatIf}
Icon: PowerShell



Note that we have used two TC parameter; %F and %T,... see TC help what they are for.
Also note that we have to use three double quotes instead of one to please each command interpreter on the way.



Try it out and read the output in the PoSh console,
and if it looks fine, remove the "-WhatIf" part to really create the directories.



For more info just ask
or see https://www.google.de/search?q=powershell+for+beginners



HTH? :D
User avatar
Gral
Power Member
Power Member
Posts: 1460
Joined: 2005-01-26, 15:12 UTC

Re: How to create list of folders from selected names

Post by *Gral »

Umbardacil wrote:Hi guys!

I wonder if there already exists a button, which will create list of directiories in " target" panel from names (files or directories) which I mark on the "source" panel?
Copy code, then right click on empty space on buttonbar, paste

Code: Select all

TOTALCMD#BAR#DATA
%comspec% /c for /F  "delims=" %N in
(%F) do md "%T%%N"
%COMMANDER_EXE%,34
Create directories in target panel from selected source panel names

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

Post by *Stefan2 »

2Gral

that's fine for the "english world" only, not for users whit umlauts in there file names.
Not to mention unicode.





 
Umbardacil
Junior Member
Junior Member
Posts: 3
Joined: 2017-06-20, 05:17 UTC

Post by *Umbardacil »

Thank you both gents for quick lesson. I see that there's whole world to discover for me with TC
User avatar
Phred
Senior Member
Senior Member
Posts: 375
Joined: 2009-06-16, 15:24 UTC
Location: SEAu

Re: How to create list of folders from selected names

Post by *Phred »

Gral wrote:
Umbardacil wrote:Hi guys!

I wonder if there already exists a button, which will create list of directiories in " target" panel from names (files or directories) which I mark on the "source" panel?
Copy code, then right click on empty space on buttonbar, paste

Code: Select all

TOTALCMD#BAR#DATA
%comspec% /c for /F  "delims=" %N in
(%F) do md "%T%%N"
%COMMANDER_EXE%,34
Create directories in target panel from selected source panel names

1
-1
I believe this code deserves an entry in TC's Wiki. Such a simple solution for something many would not even think is possible.
And that includes the Copy, Paste right-click on the Button Bar space. Who'da thought.

Tags: create folders directories folder directory selected names
Regards, PhredE
Licence holder since 1999
Awaiting a $D donors-token for the title-bar so we can display that we have donated further.
User avatar
nsp
Power Member
Power Member
Posts: 1803
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Post by *nsp »

If you do not want to copy full folder structure, you can use

Code: Select all

xcopy /t /e <Source> <target>
you can also use TCBL to create a batch to process your selection, this should automatically take care of codepage.

Code: Select all

command :<path to tcbl.exe>
parameter: -q %L md "%T$n"
or
parameter: -q %L xcopy /t/e "$f" "%T$n"
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

2Stefan2
that's fine for the "english world" only, not for users whit umlauts in there file names.
Not to mention unicode.
This button will work with unicode names:

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
md %T%S
%COMMANDER_EXE%,34
Create directories in target panel from selected source panel names

1
-1
but there is a limit of 32767 characters in the command line - so that means that if the target path is for example 50 characters long there will be room for making between 528 and 546 8-character long directories (with / without spaces in the filename).
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
Stefan2
Power Member
Power Member
Posts: 4133
Joined: 2007-09-13, 22:20 UTC
Location: Europa

CHCP 1252 for Western Europe ANSI CP umlauts

Post by *Stefan2 »

2petermad

Thanks, using %S is a nice solution I think not about often.





- - -


Another alternative for the above code of Gral to work with 'umlauts'
would be to utilize the 'chcp' DOS command to change the CP to the WindowsTM system codepage, like 1252 for Western Europe ANSI CP:

Code: Select all

TOTALCMD#BAR#DATA
cmd /c chcp 1252 
& cmd /c for /F  "delims=" %%N in (%F) do md "%T%%N"
%COMMANDER_EXE%,34
Create directories in target panel from selected source panel names

1
-1


Alternatively for Unicode need we can change the %F
to %UF or %WF, press F1 in button dialog to read more about.





 
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

lternatively for Unicode need we can change the %F
to %UF or %WF, press F1 in button dialog to read more about.
I tried with %UF and %WF in the code suggested by Gral - but couldn't make it work
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
nsp
Power Member
Power Member
Posts: 1803
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Post by *nsp »

petermad wrote:
lternatively for Unicode need we can change the %F
to %UF or %WF, press F1 in button dialog to read more about.
I tried with %UF and %WF in the code suggested by Gral - but couldn't make it work

To use utf8 from command processor, you need to change code-page to 65001 before processing the file, you also need to remove the UTF8 BOM generated by TC for %UF file. (or the first line will be not what you expect)
to see correct behavior, you also need t have correct font for your cmd window but first, you also need to ensure that command line is well quoted to have chcp and for are executed in same interpreter....

To my knowledge command processor does not support utf16 / utf32 even if code page exists in windows system (1200, 1201, 12000,12001)
User avatar
milo1012
Power Member
Power Member
Posts: 1158
Joined: 2012-02-02, 19:23 UTC

Post by *milo1012 »

petermad wrote:...
I tried with %UF and %WF in the code suggested by Gral - but couldn't make it work
nsp wrote:To my knowledge command processor does not support utf16 / utf32 even if code page exists in windows system (1200, 1201, 12000,12001)
Cmd.exe supports Unicode (i.e. UTF-16) natively, no need to hack around with chcp. The only problem is displaying the characters.
See e.g. http://www.ghisler.ch/board/viewtopic.php?p=294509#294509 for an example.
I haven't tried it myself, but you could probably mod the example in the thread to make it work with "md".
TC plugins: PCREsearch and RegXtract
User avatar
nsp
Power Member
Power Member
Posts: 1803
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Post by *nsp »

milo1012 wrote: Cmd.exe supports Unicode (i.e. UTF-16) natively, no need to hack around with chcp. The only problem is displaying the characters.
See e.g. http://www.ghisler.ch/board/viewtopic.php?p=294509#294509 for an example.
I haven't tried it myself, but you could probably mod the example in the thread to make it work with "md".
Please give a try....
The correct understanding of /U is
/U Output UNICODE characters (UCS-2 le)
These options will affect piping or redirecting to a file.
Most common text files are ANSI, use these switches
when you need to convert the character set.
The main usage of /u is to create a bom less utf-16 output from ansi command/inputs
This does not indicate that cmd will be able to interpret unicode batch file nor able to process unicode command, unicode filename.... for /F will stop at first 0 char ......
Post Reply