Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Create multiple folders from Terminal' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create multiple folders from Terminal
Authored by: lts on Apr 25, '06 08:10:30AM

You can try this: if you have a list of names of new directories that you want to create--e.g., call it "list":

cat list | xargs mkdir -vp

xargs will take the lines from its input [the output from cat], combine them into a single line and pass that line as additional arguments to the command specied as xargs' 1st argument--in this case, "mkdir -vp". If the resulting line would be too long [there IS an upper limit on the length of your argument string], xargs will invoke the command multiple times with segments of the list that "fit".

As kircmc mentioned, be sure that the folder names in the list contain no spaces, or are enclosed in quotes, else you'll get one folder per word on the line.

See the mkdir man page for info on the 'v' and 'p' options. Also, see the xargs man page for more info.



[ Reply to This | # ]