|
Answer» Hiya. I'm running a script to automatically CREATE directories. The script so far looks like this:
*************************************** mkdir companies mkdir candidates cd companies
cat ../companies.cfg | perl -e "while (<>) {chomp;mkdir($_)}"
cd.. cd candidates
cat ../candidates.cfg | perl -e "while (<>) {chomp;mkdir($_)}"
cd..
*****************************
The candidates.cfg and companies.cfg simply contain the directory names to be CREATED in each of those to sub directories.
Anyway, this script needs to be run so the same directory structure appears in all the parent folders. For example
1/companies/directory 1 1/companies/directory 2 1/candidates/directory 1 1/candidates/directory 2
2/companies/directory 1 2/companies/directory 2 2/candidates/directory 1 2/candidates/directory 2
and so forth.
The parent directories (i.e. 1, 2, etc) have already been created. There are around 5000 of them.
What I need to know is how to autotmatically change to the different directories, run the script I have so far, then cd.. back to the parent and move onto the next directory.
Any ideas how?
JonYou're going to have fun using a for-in-do loop with EITHER a generic LIST of directories or the output of a dir command as its parameters. If you have previously made some of the directories, change all
MD TARGET
commands to
if not exist target\nul: md target
to prevent errors when creating directories.
|