Page 1 of 1

Maintain File Path Structure

Posted: 20 Sep 2010 06:59
by spoonybard
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.

Re: Maintain File Path Structure

Posted: 20 Sep 2010 07:15
by amel27

Code: Select all

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

Re: Maintain File Path Structure

Posted: 20 Sep 2010 07:22
by spoonybard
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.

Re: Maintain File Path Structure

Posted: 20 Sep 2010 07:40
by amel27
spoonybard, yes, it copy *.user files with relative path
try, not ask... ;)
see "xcopy /?" for many others options

Re: Maintain File Path Structure

Posted: 20 Sep 2010 08:28
by spoonybard
Works perfect, thanks. Yeah, got a little too question happy without trying. my bad. :wink:

Re: Maintain File Path Structure

Posted: 20 Sep 2010 17:56
by orange_batch
...Noah Antwiler?