Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Loop text file and create directories

Posted on 2014-02-09
2
Medium Priority
?
235 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 29

Accepted Solution

by:
becraig earned 2000 total points
ID: 39846177
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
ID: 39846541
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Screencast - Getting to Know the Pipeline
Suggested Courses

926 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