Discussions
Categories
Groups
Advertisement
Child Item
Home
Topics
Technology & Internet
Software & Web Development
Development
Recreating a directory structure
TinCool
Okay, I've got a problem which is turning in to a large one. I'm doing some maintenance on one of my hard drives which has a few hundred directories. I want to be able to recreate the directory structure on another drive. The tree command is very useful however, it would involve a lot of manual work to manipulate the tree by adding in all the cd and md commands, plus missing out on one or two would not be good.
Basically, does anyone know of a good batch program that can recreate a directory structure either from some kind of a flat file (the results from the tree command possibly) or from another location ?
Cheers,
TC
Find more posts tagged with
Quick Links
All Categories
Recent Posts
Activity
Unanswered
Groups
Best Of
Advertisement
Advertisement
Comments
Hobbes
XCOPY.EXE
I'm pretty sure someone asked this question before though.
Other way.
dir /s/b/ad > dirlist.txt
suppose you could then use that text file.
TinCool
Thanks Hobbes. The output of that directory command is a good start. I can use this. V. straight forward to add in the md command.
bonkey
If you read up on the FOR command in DOS command shell / NT CMD shell, you should find it possible to write the whole lot as a batch script which needs no maintenance.
The basic steps are :
1) dir /s/b/ad to a file, as per Hobbes suggestion
2) use FOR /F to process this file. You should be able to get it to parse each line to get you the directory name (absolute or from some base point, depending on what you're trying to do), which you can then process with an MD command.
After that, its just adding in fancy tweaks....allowing the program to have source and destination passed in from the command line for example, or error handling, echoing output, etc. etc. etc.
jc