Solved

Loop text file and create directories

Posted on 2014-02-09
2
230 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

615 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