Solved

Loop text file and create directories

Posted on 2014-02-09
2
225 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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

911 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

18 Experts available now in Live!

Get 1:1 Help Now