bduenges
asked on
Folder Copy
Each night I need to copy certain sub folders from one server to another. How can I set up the copy? For example, I have a folder structure as follows: Main Folder called Aircraft with subfolders called 011 etc, then subfolders under that called A, B, C with subfolders under those called Drafts, Final Documents, Word. I need to copy the structure over to another server, but the only files I need are the ones under Final Documents. Does anyone have a idea on how to do this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
xcopy can be used to copy the folder structure, then you can create a batch file to copy just the files from the folders you want with xcopy as well.
If you only have those two subfolders you're not interested in (or, say, a limited amount of folders you don't want, with known names), a relatively simple robocopy command will do the trick.
Unfortunately, robocopy doesn't have an "include dirs" switch, you can only exclude folders.
robocopy.exe D:\test\test\aircraft D:\temp\aircraft /L /e /xd "drafts" "word"
You can run it with /L for testing, which will only list the files and folders, but not actually copy anything.
Unfortunately, robocopy doesn't have an "include dirs" switch, you can only exclude folders.
robocopy.exe D:\test\test\aircraft D:\temp\aircraft /L /e /xd "drafts" "word"
You can run it with /L for testing, which will only list the files and folders, but not actually copy anything.
ASKER
This Product worked great! Thanks!
Structure:
XCOPY /t /e \\server1\share \\server2\share
Files only from Final Documents. My first thought is to use XCOPY /L and find Final Documents. In a for loop copy these files.
for /f "tokens=*" %%a in ('xcopy /L /s "\\server1\share" "\\server2\share" ^| find /i "\Final Documents\"') do
Open in new window