Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Recreating a directory structure

Options
  • 21-12-2002 11:15pm
    #1
    Registered Users Posts: 2,894 ✭✭✭


    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


Comments

  • Registered Users Posts: 21,264 ✭✭✭✭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.


  • Registered Users Posts: 2,894 ✭✭✭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.


  • Registered Users Posts: 15,443 ✭✭✭✭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


Advertisement