Subtracting 1 year from today example:
@echo off
echo Todays date is %date:~4,2%-%date:~7,2%-%date:~10,4%
echo one year back...
set /a yearback=%date:~10,4%-1
Echo is %date:~4,2%-%date:~7,2%-%yearback%
pauseHere is what you can do with this. Say you have a "Junk" folder and you only want keep items for 1 year. Using the above method you can subtract a year in the batch file and then using the xcopy and delete commands copy all old files to a temp folder and delete them all. I have provided an example below of this.
@echo off
Echo #####################
Echo This tool will move old files to a temp folder for review
Echo #####################
set /a yearback=%date:~10,4%-1
Xcopy C:\old_folder\* /s /d:%yearback%-%date:~7,2%-%date:~10,4% C:\review_folder\
pause
exit