Solved

Loop text file and create directories

Posted on 2014-02-09
2
224 Views
Last Modified: 2014-02-09
Hello,

I need to look through all lines in a text file and create a directory for each line.  The text file might read something like:

John
Beth
Sam

I need to create directories for each of these names by looping through the text file.

Thanks in advance for any help.
0
Comment
Question by:crash1624
2 Comments
 
LVL 28

Accepted Solution

by:
becraig earned 500 total points
Comment Utility
for /f  %a in (file.txt) do mkdir %a

That is all you need from a simple perspective.
0
 
LVL 43

Expert Comment

by:Steve Knight
Comment Utility
You mightto not needin this ifis example isand short oneof word names,  but FYI that will only work upto first space on line if there dirs with names in... and won't work in a batch file.   Add "tokens=*" after the /f to stop it losing the rest of each line, and use %%a instead of %aif you put it in a batch file...

Steve
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now