copy_files_older_than_x_days

These days I tried to create a script that will copy the files older than 40 days from a backup folder to another location. I found a handy method which allows the copying of old files from a directory, using XXCOPY. This tool provides a logical extension to XCOPY and adds many innovative features.

Below is a small batch script that does the job:

@echo on

set olderthan=40
set source=C:workBT
set destination=C:workcopy

:: /E Copies directories and subdirectories, including empty ones
:: /Po0 Suppresses warning on file-overwrite (Legacy /Y)
:: /DB# Copies files that were changed on or before days ago.
xxcopy %source% %destination% /E /Po0 /DB#%olderthan%