• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 288
  • Last Modified:

Create multiple folders from text file with multiple sub directories under each folder.

I'm familier with creating folders from a text file but only to one level.  I need to create thousands of folders based off of a text file and have multiple subdirectories under each folder from the text file.
The text file would contain thousands of employee numbers.  Each folder labled as the employee number would have the same subdirectories.

eg.
(employee#1)/folder 1
                      /folder 2
                      /folder 3
(employee# 2/folder 1
                      /folder 2
                      /folder 3
0
DerFuzh
Asked:
DerFuzh
1 Solution
 
knightEknightCommented:
Is the above a sample of how the text file is formatted?  If not, please post a small sample of the actual test file (change the emp numbers if necessary).  
0
 
Bill PrewCommented:
I think a small BAT file like this should do the trick, or am I missing something?

@echo off
for /F "usebackq tokens=*" %%A in ("listfile.txt") do (
  md "c:\%%~A"
  md "c:\%%~A\folder 1"
  md "c:\%%~A\folder 2"
  md "c:\%%~A\folder 3"
)

Open in new window

~bp
0
 
Steve KnightIT ConsultancyCommented:
Yup though I guess I'd do:

@echo off
cd /d d:\users
for /f "usebackq tokens=*" %%A in ("listfile.txt") do (
  md "%%~A"
  md "%%~A\folder 1"
  rem etc.
)

not for points obviously.... same as bills except for the cd into the base directory first - which I think Bill could probably manage himself :-)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
DerFuzhAuthor Commented:
Perfect!  That's just what I needed...CHEERS!
0
 
Bill PrewCommented:
Steve, just for intellectual discussion, I actually prefer mine.  While the code is a little longer, I feel it's a bit safer.  In the CD approach, if the folder doesn't exist, or the CD fails for any reason, we likely create the new folders under some other directory where we didn't want them.

In my case, the folders are always going to end up where we want them, or worse case the MD fails and no folder is created.

Hope that reasoning makes sense...

~bp
0
 
Steve KnightIT ConsultancyCommented:
A very good point Bill!

Steve
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now