Atlantikdiver
Atlantikdiver

Reputation: 142

Batch: Forfiles that are older than date copy them

i try to create a batch script, that copy all files that are older than a date (DD-MM-YYYY) in another folder.

@echo off
set ARCHIV=%DATE:~0,2%%DATE:~2,2%%DATE:~4,6%

mkdir %ARCHIV%

forfiles -p "c:\" -s  -d 01.01.2002 -c "cmd /c copy c:\%ARCHIV%\"
pause

The Error Code is: ERROR: ARgument/Option invalid - 'c:\11.06.2014"'.

Tip in "FORFILES /?" to show the Syntax Please press any key . . .

Does somenone know where my mistake is ?

regards

Upvotes: 0

Views: 2202

Answers (1)

Loïc MICHEL
Loïc MICHEL

Reputation: 26140

you can use xcopy /D

from xcopy /?

/D:mm-dd-yyyy Copy files changed on or after the specified date. If no date is given, copy only files whose source date/time is newer than the destination time.

Upvotes: 1

Related Questions