Windows Batch Script to recursively copy files
https://gist.github.com/Penderis/950c914afe0e5b6cc4ee
@echo off
CLS
setlocal EnableDelayedExpansion
REM Changes root path to relative of current bat folder
pushd "%~dp0"REM finds files in provided .txt file and copies them to destination directory
REM CHECK FOR ADMIN RIGHTS
COPY /b/y NUL %WINDIR%\06CF2EB6-94E6-4a60-91D8-AB945AE8CF38 >NUL 2>&1
IF ERRORLEVEL 1 GOTO:NONADMIN
DEL %WINDIR%\06CF2EB6-94E6-4a60-91D8-AB945AE8CF38 >NUL 2>&1:ADMIN
REM GOT ADMIN RIGHTS
COLOR 1F
ECHO Hi, %USERNAME%!
ECHO Please wait...set /p DESTDIR="Copy files to:"%=%
set /p SEARCHDIR="Copy files from:"%=%
@echo.
@echo Please check folder name for accuracy.
@echo Copy files to: %DESTDIR%
@echo Copy files from: %SEARCHDIR%
set /p CORRECTFOLDERS="Are these correct? (please check spelling) y/n:"
if '%CORRECTFOLDERS%'=='y' GOTO:YESANSWER
if '%CORRECTFOLDERS%'=='n' GOTO:NO_ANSWER
COLOR 2F
ECHO.
PAUSE
GOTO:EOF:NONADMIN
REM NO ADMIN RIGHTS
COLOR 4F
ECHO.
ECHO PLEASE RUN AS ADMINISTRATOR
ECHO.
pause
GOTO:EOF:YESANSWER
@echo.
@echo you answered yes
@echo.
if exist %DESTDIR% GOTO:READDATA
if not exist %DESTDIR% md %DESTDIR%&GOTO:READDATA
PAUSE:NOANSWER
@echo.
@echo you answered no
set /p TRYAGAIN="Try again? y/n:"
if '%TRYAGAIN%'=='y' GOTO:YESANSWER
if '%TRYAGAIN%'=='n' GOTO:EXITPROGRAM
PAUSE:EXIT_PROGRAM
@echo.
@echo "So fucking sorry"
PAUSE
GOTO:EOF:READDATA
@echo.
set /p GETFILENAMES="What is the name of the text file your filenames are stored in?"%=%
if exist %GETFILENAMES%.txt @echo We will now read and copy the files for you, have some coffee might take awhile & GOTO:WRITEDATA
if not exist %GETFILENAMES%.txt @echo Filename does not match, please type only the name without .txt extention & GOTO:READDATA
PAUSE:WRITEDATA
@echo.
@echo reading file name...
for /f "usebackq delims=" %%a in ("%GETFILENAMES%.txt") do (
for /r "%SEARCHDIR%" %%b in ("%%a*") do (
@echo Copy Started...
copy "%%b" "%DESTDIR%\%%~nxb"
)
)
@echo Copy finished, please review actions. Lekker Man.
PAUSE
</pre>