Maintain File Path Structure

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
spoonybard
Posts: 3
Joined: 20 Sep 2010 06:51

Maintain File Path Structure

#1 Post by spoonybard » 20 Sep 2010 06:59

I have a single directory with multiple sub-directories and I want to copy all the "*.user" files within the sub-directories into a new main directory. I found the code to that except that I have to both maintain the original file path structure as well as change one of the folder names in it.

Here is an example:

Original File - D:\Projects\APPS\Branch1\Project1\MyFile.user

What I want it to be copied to - D:\Projects\APPS\Branch2\Project1\MyFile.user

The "Project1" path can be a single level or have further sub-directories after it.

Any help on this would be greatly appreciated.

amel27
Expert
Posts: 177
Joined: 04 Jun 2010 20:05
Location: Russia

Re: Maintain File Path Structure

#2 Post by amel27 » 20 Sep 2010 07:15

Code: Select all

xcopy /S "D:\Projects\APPS\Branch1\*.user" "D:\Projects\APPS\Branch2\"

spoonybard
Posts: 3
Joined: 20 Sep 2010 06:51

Re: Maintain File Path Structure

#3 Post by spoonybard » 20 Sep 2010 07:22

So the syntax for the destination will maintain everything that comes after Branch1\ up to the *.user file? So if for example one of the *.user files is located in "Branch1\Project\InnerFolder\MyFile.user", the destination syntax will copy the file to -> "Branch2\Project\InnerFolder\MyFile.user"?

Thanks.

amel27
Expert
Posts: 177
Joined: 04 Jun 2010 20:05
Location: Russia

Re: Maintain File Path Structure

#4 Post by amel27 » 20 Sep 2010 07:40

spoonybard, yes, it copy *.user files with relative path
try, not ask... ;)
see "xcopy /?" for many others options

spoonybard
Posts: 3
Joined: 20 Sep 2010 06:51

Re: Maintain File Path Structure

#5 Post by spoonybard » 20 Sep 2010 08:28

Works perfect, thanks. Yeah, got a little too question happy without trying. my bad. :wink:

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: Maintain File Path Structure

#6 Post by orange_batch » 20 Sep 2010 17:56

...Noah Antwiler?

Post Reply