Create mulitple folders using text file

Hi,

Im currently trying to create multiple folders using Directory Opus 9. I heve the name of the folders in a text file and do not want to create them manualy.

Does anyone know how i can solve my problem using Opus?

Thanks!

If the folders in your text file are arranged one folder per line like this:

D:\Folder 1\Folder 2\Folder 3
C:\Another Folder 1\Folder 2\Folder 3
D:\Yet Another Folder 1\Folder 2\Folder 3

then the following button should work (at least it does for me with opus 9005 and XP Pro SP2)

<?xml version="1.0"?> <button backcol="none" display="both" textcol="none"> <label>Create folders from file</label> <icon1>#newcommand</icon1> <function type="batch"> <instruction>@echo off</instruction> <instruction>for /f &quot;tokens=*&quot; %%a in (&apos;type &quot;D:\test folder\folder names.txt&quot;&apos;) do (</instruction> <instruction>md &quot;%%a&quot;</instruction> <instruction>)</instruction> </function> </button>

Note in the button code above you would need to change my "D:\test folder\folder names.txt" file to the full path of your text file.

Well, how exactly does the information appear in the text file? It would be easier if each folder name you wanted to create were separated by commas... then you could use Leo's setclip utility to read the contents of the file to the Clipboard, and then run the command CreateFolder FROMCLIPBOARD from an Opus button or hotkey.

Quick edit: Actually, this would only work if you ALSO already had the Create Folder dialogs option to 'Create multiple folders (comma-separated)' selected. Looks like there's no good way to invoke that behaviour through the internal function. BUT... you could always just enable the option and LEAVE it enabled if you don't often create folders with commas in the actual folder name...

The whole kaboodle would like:

@runmode hide
setclip -f -l {f}
dopusrt /cmd CreateFolder FROMCLIPBOARD

And you can get Leo's setclip tool from here.

If it's just a one-off creation then I would turn the list of names into a batch file using text-editor macros (to put "mkdir" and some quotes around each folder name), then run the batch file.

(You could also turn it into an Opus command/button in a similar way, but that doesn't seem worth it for a one-off.)

If you need to do it a lot then the other suggestions seem good. Note that Steje's idea will go wrong if you need to create folders that have "," in their names. :slight_smile:

Steje, is that "dopusrt /cmd" needed?

Thanks JohnZeman,

Your button works great!!! But as steje already thought the file which contains my folder names are comma seperated.

Thanks for the help!!

Steja,

I followed the link you gave me and ended up with:

CreateFolder NAME="{clip|noext}"
@nofilenamequoting

When i copy the text from my file and hit the button i made i get one folder containing all the names.

example: d:\folder1,folder2,folder3

How do i get it to create sepperate folders?

Thanks again!!!

[quote="nudel"]If it's just a one-off creation then I would turn the list of names into a batch file using text-editor macros (to put "mkdir" and some quotes around each folder name), then run the batch file.

(You could also turn it into an Opus command/button in a similar way, but that doesn't seem worth it for a one-off.)

If you need to do it a lot then the other suggestions seem good. Note that Steje's idea will go wrong if you need to create folders that have "," in their names. :slight_smile:

Steje, is that "dopusrt /cmd" needed?[/quote]

I need to do this more often than I like :slight_smile: When if followed steja's link i read that setclip was not needed so i tried to make my own code ( see previous post) however sins I am not a genious script builder it blew up in my face :cry:

I don't really know about this, but just from reading through this thread it seems that possibly you need to follow the following advice:

I will use the create folder option (did not know it was there until now :confused: )

Thank you all for your info and help!

@nudel:

yeah, it looks like the dopusrt /cmd is needed. If it's not used, I get the 'previous' contents of the clipboard (whatever is in tere before your tool reads the data from the file) used by the CreateFolder function.

@ISIDE:

Since you've mentioned that the text file with the folder list you want to create is indeed comma separated... then doing things like I mentioned will work for you without alteration.

Yes, the link I posted does suggest that setclip is somewhat obsolete... but not if you want to read the contents of a file... which the new bulit-in Opus function doesn't let you do.

What rcoleman1943 said about your question is correct. Try using the regular 'Create Folder' button on the default Opus toolbar and you'll see the option we're talking about with a checkbox next to it that let's you do what you want.

Oh... and FWIW... when I wrote the bit about "if your file list is comma separated" I KNEW without a doubt that it was gonna be John Zeman who would reply with a for loop batch file for "if your file list is line by line".

:slight_smile:

Cheers John!