Solved

Loop text file and create directories

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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

751 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