Multiple folders creation "MD" command.

English support forum

Moderators: sheep, Hacker, Stefan2, white

Pakylibin
Junior Member
Junior Member
Posts: 2
Joined: 2019-05-18, 03:04 UTC

Multiple folders creation "MD" command.

Post by *Pakylibin » 2019-05-18, 03:27 UTC

I was looking for create SO MANY folders...

Let me SHOW, HOW MANY folders...

Imgur link : https://imgur.com/icwILHb :D :D

I am producting an archived folder with subfolders about the "Enciplopédia da Conscienciologia", so this way I had tired with hand working of put commas at my future directories, when I put all the commas and started the .bat executable... The command errored on the spaced and created the names wrong...

HELP ME FOR TREAT ALL THIS FOLDERS...
I need an way for make sure that the directory's names gonna spaced.

Pakylibin
Junior Member
Junior Member
Posts: 2
Joined: 2019-05-18, 03:04 UTC

Re: Multiple folders creation "MD" command.

Post by *Pakylibin » 2019-05-18, 03:29 UTC

I am there waiting for a savior.

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

Re: Multiple folders creation "MD" command.

Post by *Stefan2 » 2019-05-18, 10:43 UTC

Pakylibin wrote:
2019-05-18, 03:27 UTC
I was looking for create SO MANY folders...
Imgur link : https://imgur.com/icwILHb

...so this way I had tired with hand working of put commas at my future directories,
when I put all the commas and started the .bat executable... The command errored on the spaced and created the names wrong...


Learn some DOS basics and put the folder names "inside quotes".








 
Inofficial FAQs || WIKI (Deu/Eng) || TC Home (What's new? // FAQ // Download // Order // Addons // Tools // Plugins)
Erst wenn der letzte Baum gefällt oder die letzte Biene verendet ist, werden die Leute verstehen warum Umweltschutz wichtig ist.

User avatar
Usher
Power Member
Power Member
Posts: 584
Joined: 2011-03-11, 10:11 UTC

Re: Multiple folders creation "MD" command.

Post by *Usher » 2019-05-18, 11:41 UTC

Pakylibin wrote:
2019-05-18, 03:29 UTC
I am there waiting for a savior.
There are sooo many good text editors which support regular expressions… Choose one of them and you will have every name in a separate line.
Regards from Poland
Andrzej P. Wozniak

User avatar
clifford_cooley
Junior Member
Junior Member
Posts: 40
Joined: 2019-03-05, 06:04 UTC
Location: USA

Re: Multiple folders creation "MD" command.

Post by *clifford_cooley » 2019-05-18, 11:45 UTC

Try this vbs(visial basic script) file I rebuilt for you. I already had one similar created for myself.

Code: Select all

'   Create an array of all folder names
MyArray=Array( "Conscientia libera (CL)","Conscientia transmigrans","Consciex anticonflictiva" ):

'   Loop through listings in the array, and create folder if it does not exist
For count = 0 To uBound(MyArray):
  strFolder = MyArray(count):
  set objFSO = createobject("Scripting.FileSystemObject"):
  if objFSO.FolderExists(strFolder) = False then objFSO.CreateFolder strFolder:
Next:
Note: The script is a plain text file with a .vbs extension. You can name the script anything you wish as long as the extension is .vbs.
License #116347

User avatar
ts4242
Power Member
Power Member
Posts: 2081
Joined: 2004-02-02, 20:08 UTC
Contact:

Re: Multiple folders creation "MD" command.

Post by *ts4242 » 2019-05-18, 19:45 UTC

Stefan2 wrote:
2019-05-18, 10:43 UTC
Learn some DOS basics and put the folder names "inside quotes".
You can do it easily with Windows Notepad, just replace , with "," all names will enclosed between quotations except first and last one, so enclose them manually.

User avatar
Usher
Power Member
Power Member
Posts: 584
Joined: 2011-03-11, 10:11 UTC

Re: Multiple folders creation "MD" command.

Post by *Usher » 2019-05-18, 20:13 UTC

ts4242 wrote:
2019-05-18, 19:45 UTC
You can do it easily with Windows Notepad
Did you try to do it in Windows XP or earlier system?
Regards from Poland
Andrzej P. Wozniak

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

Re: Create multiple folders with VBScript or PowerShell or DOS MD makedir

Post by *Stefan2 » 2019-05-18, 20:56 UTC

Oh, so many help? Great forum. Here is my solution, a VBScript:

- read in whole "Homines.txt"
- split long string at comma into an array
- for each array item
- - - trim whitespaces
- - - check if folder already exists, if not, create the folder


Code: Select all

' Total Commander VBScript "Create Folders from List.vbs" by Stefan, 2019-05-18, v0.01
' Found at: https://ghisler.ch/board/viewtopic.php?p=355349#p355349

'// U S E R   S E T T I N G S
'- go to your main folder for to create the new folders
'- have the text file with the list of folders to create
strFolderList = "Homines.txt"

'- save this vbs code as plain text file "Create Folders from List.vbs"
'- double click this VBS


'// T H E   C O D E - - - - - - - - - - - - - - - - - - 
Set FSO = CreateObject("Scripting.FileSystemObject")
Set oTextStream = FSO.OpenTextFile(strFolderList,1)
strFolderList = oTextStream.ReadAll
oTextStream.Close
FldArray = split(strFolderList,",")
For FldIndex=0 To UBound(FldArray)
    strFldName= trim(FldArray(FldIndex))
    If strFldName <> "" Then
          '  DEBUG 
            'comment-out the next two lines if wanted:
             MsgBox "Create : " & strFldName
            If FldIndex=4 Then WScript.Quit
         '  /End DEBUG

        'un-comment next line for to create the folders:
        'If not (FSO.FolderExists(strFldName)) Then FSO.CreateFolder(strFldName)
    End If 
Next
'- - - - - - - - - - - - - - - - - - - - - - - - - - - 




HTH?

>> below the same in PowerShell > https://ghisler.ch/board/viewtopic.php?p=355561#p355561

 
Inofficial FAQs || WIKI (Deu/Eng) || TC Home (What's new? // FAQ // Download // Order // Addons // Tools // Plugins)
Erst wenn der letzte Baum gefällt oder die letzte Biene verendet ist, werden die Leute verstehen warum Umweltschutz wichtig ist.

User avatar
ts4242
Power Member
Power Member
Posts: 2081
Joined: 2004-02-02, 20:08 UTC
Contact:

Re: Multiple folders creation "MD" command.

Post by *ts4242 » 2019-05-18, 21:56 UTC

Usher wrote:
2019-05-18, 20:13 UTC
ts4242 wrote:
2019-05-18, 19:45 UTC
You can do it easily with Windows Notepad
Did you try to do it in Windows XP or earlier system?
I'm talking about using Windows Notepad to create folders but to enclose names between quotation mark to enable OP's .bat file creating folder with names contain space character.

User avatar
Usher
Power Member
Power Member
Posts: 584
Joined: 2011-03-11, 10:11 UTC

Re: Multiple folders creation "MD" command.

Post by *Usher » 2019-05-19, 02:30 UTC

2ts4242
Did you really try to use "Replace all" in a large text file with Notepad in Windows XP?
Regards from Poland
Andrzej P. Wozniak

User avatar
clifford_cooley
Junior Member
Junior Member
Posts: 40
Joined: 2019-03-05, 06:04 UTC
Location: USA

Re: Multiple folders creation "MD" command.

Post by *clifford_cooley » 2019-05-19, 02:42 UTC

I always use Wordpad myself. I don't care much for Notepad.
License #116347

User avatar
ts4242
Power Member
Power Member
Posts: 2081
Joined: 2004-02-02, 20:08 UTC
Contact:

Re: Multiple folders creation "MD" command.

Post by *ts4242 » 2019-05-19, 05:38 UTC

Usher wrote:
2019-05-19, 02:30 UTC
2ts4242
Did you really try to use "Replace all" in a large text file with Notepad in Windows XP?
Of course not, but OP is using Notepad (see his screenshot) therefore I mentioned it, in addition this is a simple task, so no need to use advanced text editor.

User avatar
Usher
Power Member
Power Member
Posts: 584
Joined: 2011-03-11, 10:11 UTC

Re: Multiple folders creation "MD" command.

Post by *Usher » 2019-05-19, 12:14 UTC

2ts4242
Don't you think that the supposed command is too long to fit in a single line?
How do you want to split the content to many lines in Notepad?
Regards from Poland
Andrzej P. Wozniak

User avatar
clifford_cooley
Junior Member
Junior Member
Posts: 40
Joined: 2019-03-05, 06:04 UTC
Location: USA

Re: Multiple folders creation "MD" command.

Post by *clifford_cooley » 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. From MD help text, each nested folder* needs its own MD command line.

https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/md

Or type one of the following from TC command-line box.
  • cmd /k help md
  • cmd /k md /?
*nested folder - https://www.yourdictionary.com/nested-folder
License #116347

User avatar
clifford_cooley
Junior Member
Junior Member
Posts: 40
Joined: 2019-03-05, 06:04 UTC
Location: USA

Re: Multiple folders creation "MD" command.

Post by *clifford_cooley » 2019-05-19, 14:03 UTC

clifford_cooley wrote:
2019-05-19, 13:32 UTC
Nothing I have ever read suggest more than one folder can be created from the same script line.
After taking a few minutes trying different syntax, I have created multiple folders using the following command.

MD "Folder One" "Folder Two"

Notice there are no commas for parameter delimiter. So the correct edit would be to replace all the |,| with |" "| not |","|

But then there is a max character limit of 8191 (pre-XP: 2047) for each command line.
https://support.microsoft.com/en-us/help/830473/command-prompt-cmd-exe-command-line-string-limitation
License #116347

Post Reply