Copy sub folders with them files from folder a to folder b

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
moh_salah8
Posts: 14
Joined: 08 Aug 2012 09:24

Copy sub folders with them files from folder a to folder b

#1 Post by moh_salah8 » 10 Sep 2012 03:08

Hello all,

the problem
If i've one folder (a) contains many sub folders, these sub folders contain files with the same them folder name and another folder(b) contains 4 or 5 sub folders from folder (a)

I need your help to copy sub folders and them files from folder (a) to folder (b)


i hope to find your reply soon.

Thanks.

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

Re: Copy sub folders with them files from folder a to folder

#2 Post by foxidrive » 10 Sep 2012 04:49

with the same them folder name


Try writing that again, and use some punctuation.

I, for one, don't quite understand what you want to do.

moh_salah8
Posts: 14
Joined: 08 Aug 2012 09:24

Re: Copy sub folders with them files from folder a to folder

#3 Post by moh_salah8 » 10 Sep 2012 04:59

i mean if the folder name is "a", the file name in this folder is "a" .

Thanks for ur reply.

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

Re: Copy sub folders with them files from folder a to folder

#4 Post by foxidrive » 10 Sep 2012 05:12

So you have


c:\a\one\one.txt
c:\a\two\two.txt
c:\a\three\three.txt


What do you want to do with them?

moh_salah8
Posts: 14
Joined: 08 Aug 2012 09:24

Re: Copy sub folders with them files from folder a to folder

#5 Post by moh_salah8 » 10 Sep 2012 06:00

Sorry for late.

There is amendment to make the issue more clarification

We can change the batch idea to copy and replace some folders with sub folders and files to many paths.

c:\a\one\one.txt
c:\a\two\two.txt
c:\a\three\three.txt
---
c:\b\one\one.txt
c:\b\two\two.txt
c:\b\three\three.txt

I need to copy and replace them to

d:\a\one\one.txt
d:\a\two\two.txt
d:\a\three\three.txt
---------
d:\b\one\one.txt
d:\b\two\two.txt
d:\b\three\three.txt


- I need to copy sub folders with files to many paths by only one step to save a time.

sorry because i can't explain the issue as well and thanks for your patience


Thanks.

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

Re: Copy sub folders with them files from folder a to folder

#6 Post by foxidrive » 10 Sep 2012 06:06

Maybe this will do what you want.


Code: Select all

@echo off
xcopy "c:\a\*.*" "d:\a\" /s
xcopy "c:\b\*.*" "d:\b\" /s

moh_salah8
Posts: 14
Joined: 08 Aug 2012 09:24

Re: Copy sub folders with them files from folder a to folder

#7 Post by moh_salah8 » 10 Sep 2012 06:25

Not exactly,

I've this command to copy files but the folders should be .Zip

FOR /F %%G IN ('dir /b %1') DO ROBOCOPY %1\%%G\ *.* %2\%%G /z

I need it to copy folders and files without compressing them.

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

Re: Copy sub folders with them files from folder a to folder

#8 Post by foxidrive » 10 Sep 2012 07:29

What's wrong with the commands I gave?

moh_salah8
Posts: 14
Joined: 08 Aug 2012 09:24

Re: Copy sub folders with them files from folder a to folder

#9 Post by moh_salah8 » 10 Sep 2012 08:10

Your command line is fine but it works on one case.

I need command line work generally by giving it the original and the another path.

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

Re: Copy sub folders with them files from folder a to folder

#10 Post by foxidrive » 10 Sep 2012 08:14

Then add parameters to the commands.

Next time you ask for help, please describe exactly what you want.
If you want to specify paths on the command line, then say so. Give examples.

Post Reply