Last active
April 28, 2021 15:27
-
-
Save bmatthewshea/220f14fb0d421f1b1eaf5788d279e7be to your computer and use it in GitHub Desktop.
Copy/recurse folders/files using a text file. CMD / BATCH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO off | |
SET FileList=.\pathlist.txt | |
SET LOGGING=.\robocopy-copy-logs | |
REM EDIT THESE TWO PATHS BEFORE RUNNING (NO QUOTES! NO TRAILING BACKSLASH!) | |
SET Source-Path=E:\folders-under-this-root-need-copying | |
SET Dest-Path=D:\folder-under-which-to-place-copied-folders-from-E | |
REM ** XCOPY WORKS ** | |
REM FOR /F "USEBACKQ TOKENS=*" %%F IN ("%FileList%") DO (XCOPY /Q /E /C /I "%Source-Path%\%%~F" "%Dest-Path%\%%~nxF\") | |
REM ** BUT, LETS USE ROBOCOPY AND SAVE A SEPERATE LOG FOR EACH FOLDER COPIED | |
FOR /F "USEBACKQ TOKENS=*" %%F IN ("%FileList%") DO (mkdir "%Dest-Path%\%%~nxF" & ROBOCOPY "%Source-Path%\%%~F" "%Dest-Path%\%%~nxF" /E /Z /ZB /R:2 /W:3 /V /MT:32 /log:%LOGGING%\robocopy-%%~nxF.log) | |
GOTO :EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"pathlist.txt" should just have the single top-level folder name to be found under your Source-Path.
If
And
pathlist.txt has:
Then it will copy the full path and files to: