@echo off
set currday=23
echo %currday%
set currmonth=3
echo %currmonth%
set curryear=2007
echo %curryear%
::move the files from /BACKUP/ to a storage folder.
::format: [year]-[month]_Week_[week of month]
set /a currweek=(%currday%/7)+1
set currdate=%curryear%-%currmonth%_Week_%currweek%
md D:\BACKUP\%currdate%
move D:\BACKUP\*.tar.gz D:\BACKUP\%currdate%
::remove the 3 month old folder
set /a oldmonth=%currmonth%-3
if %oldmonth% LSS 0 set /a oldmonth=%oldmonth%+12
if %oldmonth% LSS 10 set oldmonth=0%oldmonth%
echo D:\BACKUP\%curryear%-%oldmonth%_Week_%currweek%
endlocal