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: Oneota on Apr 25, '06 08:50:54AM

Ah, but what if they have Double Quotes or Single Quotes in their names? How would one deal with that?



[ Reply to This | # ]
Create multiple folders from Terminal
Authored by: adrianm on Apr 25, '06 09:11:05AM
To not care about spaces, quotes, etc, and the name of dirs is in folders.txt:

perl -n -e 'mkdir($_);' < folders.txt


[ Reply to This | # ]
Create multiple folders from Terminal
Authored by: ScottTFrazer on Apr 25, '06 10:35:36AM

and _that's_ why I love perl.



[ Reply to This | # ]
Create multiple folders from Terminal
Authored by: juanfal on Apr 25, '06 10:49:05AM
perl, perl, what a nightmare.. !!!! You should use
   perl -ne 'chomp($x=$_); mkdir($x);' < dirnames.txt
and the utf8 accented etc chars are not welcome :(

[ Reply to This | # ]
Create multiple folders from Terminal
Authored by: kitzkikz on Apr 27, '06 04:11:33PM
There's no need for the chomp if you use the lowercase L switch. There's no need for the parens, semicolon, or redirection either.
perl -lne 'mkdir $_' dirnames.txt


[ Reply to This | # ]
Create multiple folders from Terminal
Authored by: osxpounder on Apr 25, '06 11:42:10AM

Doesn't do a thing for me. Not even an error.

---
--
osxpounder



[ Reply to This | # ]
Create multiple folders from Terminal
Authored by: osxpounder on Apr 25, '06 11:45:43AM

I was referring to the first perl command, when I said it did nothing for me, but I'll add that the second perl command also did nothing. If I just run "perl" on the command line, I see a process in Activity Monitor, so it's not that I lack perl.

So far, the only commands in this thread that have worked for me are those of the original post, and then the xargs suggestion immediately following.

---
--
osxpounder



[ Reply to This | # ]
Create multiple folders from Terminal
Authored by: pmccann on Apr 25, '06 08:52:23PM

Then something's fishy: I made a text file "dirnames.txt" in my home directory with the contents

one
two
three

and then executed the above command in the same directory:

perl -ne 'chomp($x=$_); mkdir($x);' < dirnames.txt

Bingo: three folders, appropriately named.

Cheers,
Paul



[ Reply to This | # ]