cyruz
cyruz

Reputation: 37

Batch Copy Script recursive

i have the following piece of code, to copy files to my usb drive silently:

@echo off 
:: variables 
/min 
SET odrive=%odrive:~0,2% 
set backupcmd=xcopy /s /c /d /e /h /i /r /y 
echo off 
%backupcmd% "C:\*.pdf" "%drive%\all\"
@echo off 
cls

I want to extend this, to copy all pdf files in the folder structure c:\ recursive. Any suggestions?

Also i want to use some patterns like *test.pdf, test*.pdf. Maybe regex would be the right way, but i dont know how to do..

Thx for your support! :) Windows isnt my friend .. :-/

Upvotes: 0

Views: 1848

Answers (1)

Bali C
Bali C

Reputation: 31231

I'm not entirely sure what you are trying to do, but if you want to copy all the pdf files from C:\ and below then this should do it

for /r C:\ %%x in (*.pdf) do xcopy %%x "%drive%\all"

Upvotes: 2

Related Questions