Filelisting to Directory creation
Moderator: DosItHelp
Filelisting to Directory creation
Ok, the title sounds a little more simple than it seems. What I am trying to do is create a batch script where given a certain directory, say "z:\" creates a directory listing of certain file types (*txt). From there, the listing then would make the folder structure from the file list in a different mapped out location, say "m:\". Sorry if this sounds confusing; I am relatively new to batch commands and scripting. Also, this would save me several man hours.
Re: Filelisting to Directory creation
So you want to create the directory structure of where your TEXT files are on one drive to another drive. That is pretty easily done with the XCOPY command. It has the /T switch to do that.
Re: Filelisting to Directory creation
Squashman wrote:So you want to create the directory structure of where your TEXT files are on one drive to another drive. That is pretty easily done with the XCOPY command. It has the /T switch to do that.
My logic is this so far:
create a dir listing as follows:
dir /s /a:-d /b /o:n *.txt > Filelisting.txt
and then run:
for /f %d in (Filelisting.txt) do md %d
I just don't know how to get to the mapped location "M:\" and run it all in one script.
Like I said, I am new to all of this and just trying to make my life a little easier.
Re: Filelisting to Directory creation
Try this:
Code: Select all
@echo off
dir /s /a:-d /b /o:n "Z:\*.txt" > Filelisting.tmp
for /f "delims=" %%d in (Filelisting.tmp) do md "M:\%%~pd" 2>nul
del Filelisting.tmp
Re: Filelisting to Directory creation
foxidrive wrote:Try this:Code: Select all
@echo off
dir /s /a:-d /b /o:n "Z:\*.txt" > Filelisting.tmp
for /f "delims=" %%d in (Filelisting.tmp) do md "M:\%%~pd" 2>nul
del Filelisting.tmp
If I have the source of the of the drive mapped to z:\ and the destination mapped to m:\ should I be able to run the batch command succesfuly from my desktop? I am trying to deduce this script and it seems like I need to have the script inside the z:\ drive. Is this correct? Thanks in advance for your all help guys.
Re: Filelisting to Directory creation
The script can be anywhere that is writable.
If you have z: and m: mapped then it should create the folders ok.
If you have z: and m: mapped then it should create the folders ok.
Re: Filelisting to Directory creation
foxidrive wrote:The script can be anywhere that is writable.
If you have z: and m: mapped then it should create the folders ok.
Foxdrive, thanks for the help! This world perfectly!