Link to home
Start Free TrialLog in
Avatar of habs1994
habs1994Flag for United States of America

asked on

File copy procedure

I have a scenario whereby I need to copy select folders (not all folder) from one folder to a bunch of other folders within the same volume, while retaining permissions.  I am familiar with xcopy and robocopy for copying a set of folders to another location but I am having trouble with the copy more than one folder to many others scenario.  Any help would be appreciated.
Avatar of Aeriden
Aeriden
Flag of United States of America image

Robocopy is the best solution for retaining permissions.  You will likely need a BAT or CMD file with a bunch of calls to Robocopy to separate the files in a single folder into multiple folders.
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of habs1994

ASKER

I've requested that this question be deleted for the following reason:

No good answers
Avatar of oBdA
oBdA

Your question was to duplicate a selection of folders to another selection of folders.
The batch script in http:#a38600205 does that; you can save it as is and run it, and it will give you a sample of what it could do.
From the information given, this is as far as we can support you; you never came back to comment and/or provide enough information for a "good answer".
Requesting #4, as http:#a38600205 and http:#a38600138 were attempts to create a dialog of understand to the best of our ability.  Authors response was 5 days after the initial expert responses without clarification to help us attain the results being sought.
At the time of my post I did not realize that there were answers posted.  This may have been due to some technical difficulties on my end here.  I do see the answers posted here now and will consider, and appreciate all advice.  I apologize for the misunderstanding.
Obda,
As someone with little experience with the sort of scripting you describe here could you provide me with a brief explanation of how your code works and where variables would need to be altered?  

Thanks
SourceRoot is the root folder of the "select folders".
Accordingly, TargetRoot is the root folder of the "other location".
SourceList is the list of source folders (inside SourceRoot) to copy to the "other location".
TargetList is the list of folders where each of the source folder's content will be copied into.
RCOptions are options for robocopy.
Just noticed that the script above contains an error in line 12, the second "%SourceRoot%" should of course be "%TargetRoot%".
Open a command prompt and run the script as it is, and see if the concept is basically what you need. If it is not, you need to provide more information how and what you want copied.
@echo off
setlocal enabledelayedexpansion
set SourceRoot=C:\Temp
set SourceList="SourceFolder 1" "SourceFolder 2" "SourceFolder 3"
set TargetRoot=D:\Temp
set TargetList="TargetFolder 1" "TargetFolder 2" "TargetFolder 3" "TargetFolder 4"
set RCOptions=/copyall /e /r:0 /w:0
for %%s in (%SourceList%) do (
	echo Processing %%s ...
	for %%t in (%TargetList%) do (
		echo ... copying to %%t
		ECHO robocopy.exe "%SourceRoot%\%%~s" "%TargetRoot%\%%~t" *.* %RCOptions%
	)
)

Open in new window

I will try it and I appreciate the help.  One other question:  In the Source and Target lists; the multiple folder listing is just seperated by " "?
The lists are space separated; the double quotes around a folder name are required if the name contains a space.