Filelisting to Directory Creation P2

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
podgodd
Posts: 10
Joined: 14 Jan 2013 14:15

Filelisting to Directory Creation P2

#1 Post by podgodd » 20 Feb 2013 09:15

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 (*.pst). From there, the listing then would make the folder structure from the file list in a different mapped out location, say "m:\" with a folder created for the .pst name as well. Sorry if this sounds confusing; I am relatively new to batch commands and scripting.

Foxidrive helped me earlier and put together this:

dir /s /a:-d /b /o:n "Z:\*.pst" > Filelisting.tmp
for /f "delims=" %%d in (Filelisting.tmp) do md "M:\"%%~na" 2>nul
del Filelisting.tmp

How would I go about adding to this to create a folder the *.pst within the listing?

Thanks in advance!

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Filelisting to Directory Creation P2

#2 Post by abc0502 » 20 Feb 2013 09:31

sorry but what do you mean with
with a folder created for the .pst name as well

the code you provided create directories when it copies the files. :!:

podgodd
Posts: 10
Joined: 14 Jan 2013 14:15

Re: Filelisting to Directory Creation P2

#3 Post by podgodd » 20 Feb 2013 09:52

abc0502 wrote:sorry but what do you mean with
with a folder created for the .pst name as well

the code you provided create directories when it copies the files. :!:


Currently the created directory only creates the folder structure up to the *.pst filename, and doesn't create a folder for the filename which I do want

Currently c:\testcase\joeblow\testing\help.pst is creating the folder structure c:\testcase\joeblow\testing

However, I would like it to create the folder structure c:\testcase\joeblow\testing\help where the filename is actually a folder.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Filelisting to Directory Creation P2

#4 Post by foxidrive » 20 Feb 2013 11:37

The code you posted above doesn't do what you said it does.

This might do what you want.

Code: Select all

@echo off
dir /s /a:-d /b /o:n "Z:\*.pst" > Filelisting.tmp
for /f "delims=" %%a in (Filelisting.tmp) do md "M:\%%~pna" 2>nul
del Filelisting.tmp

podgodd
Posts: 10
Joined: 14 Jan 2013 14:15

Re: Filelisting to Directory Creation P2

#5 Post by podgodd » 20 Feb 2013 11:46

foxidrive wrote:The code you posted above doesn't do what you said it does.

This might do what you want.

Code: Select all

@echo off
dir /s /a:-d /b /o:n "Z:\*.pst" > Filelisting.tmp
for /f "delims=" %%a in (Filelisting.tmp) do md "M:\%%~pna" 2>nul
del Filelisting.tmp



Beautiful!! Thank you so much! works like a charm

Post Reply