Who said we need to split names to many lines, the file doesn't contain any command, so it is depend on the used script how it is parse the content.
Multiple folders creation "MD" command.
Moderators: white, Hacker, petermad, Stefan2
Re: Multiple folders creation "MD" command.
Re: Multiple folders creation "MD" command.
depending on what you are using as a source for your list of folders, the challenge could be to actually handle such a long list and not the creating of the folders. I would put every folder name on a separate line and sort them alphabetically so I could add or remove folders easily, then use some tool to read line by line and create the folders. If you have not found the solution yet, it can be done in powershell or even withing excel with vba. Have you already found the solution, or do you want the powershell script?
[tridy]
License #: 79539
License #: 79539
Re: Multiple folders creation "MD" command.
What script do you mean - cmd? The picture shows Notepad with a very long single line containing a command md and a list of folders. This line is definitely too long for cmd commands.clifford_cooley wrote: ↑2019-05-19, 13:32 UTC Are we arguing about how to create an invalid syntax for a command-line command? If it is not invalid, please explain. Nothing I have ever read suggest more than one folder can be created from the same script line.
1. The list does NOT contain nested folders.clifford_cooley wrote: ↑2019-05-19, 13:32 UTC From MD help text, each nested folder* needs its own MD command line.
2. You can create nested folders using one command, f.e.
Code: Select all
md a1\a2\a3\a4\a5
https://www.itprotoday.com/windows-78/how-do-i-enabledisable-command-extensions
Oh, I see you already know what I mean. That's it. It works the same way in Windows XP. But inserting new lines is a job for regular expressions and in Windows XP you can't use Notepad even for "Replace all" (it takes long minutes…).clifford_cooley wrote: ↑2019-05-19, 14:03 UTC MD "Folder One" "Folder Two"
But then there is a max character limit of 8191 (pre-XP: 2047) for each command line.
Andrzej P. Wozniak
Polish subforum moderator
Polish subforum moderator
Re: Multiple folders creation "MD" command.
What scripting, what parsing? Why are you trying to reinvent wheel?
The simplest answer to the SUBJECT is to create batch file (a.k.a. cmd script) and it's enough to use good text editor to do it. It's just one or two "replace all" using regular expressions.
Andrzej P. Wozniak
Polish subforum moderator
Polish subforum moderator
Re: Multiple folders creation "MD" command.
in case powershell is an option, and
if you have a names.txt file with the names of the folders each on a separate line, like this:
here is a powershell script (save it as .ps1 file, and run in the same folder as names.txt file) that creates the folders:
if you have a names.txt file with the names of the folders each on a separate line, like this:
Code: Select all
MD Conscientia libera (CL)
Conscientia transmigrans
Consciex anticonflictiva
Consciex libera (CL)
Consciex Livre (CL)
Homo alienatus
Homo animalis
Homo autotortor
Homo bellicosus regressivus
Homo bellicosus transmigrabilis
...
Code: Select all
$dirs = Get-Content -Path "names.txt"
ForEach ($dir in $dirs)
{
New-Item -Path $dir -Type Directory
}
[tridy]
License #: 79539
License #: 79539
Re: Multiple folders creation "MD" command.
Good work, tridy.
You can take this even shorter:
Get-Content .\List.txt | ForEach{ New-Item -Path $_ -ItemType Directory }
or even shorter
gc .\List.txt|%{New-Item $_ -i dir}
or as TC button:
Command: PowerShell -NoExit
Parameters: gc '%P%N'|%%{New-Item $_ -i dir}
Icon: powershell
Tooltip: create folders from selected list file
- - -
or for Pakylibin original comma separated list:
(Get-Content ".\List - comma separated.txt")-split',' |ForEach{New-Item -Path $_.trim() -ItemType directory}