All pastes #586168 Raw Edit

Anonymous

public text v1 · immutable
#586168 ·published 2007-06-23 17:58 UTC
rendered paste body
@echo off
setlocal
::for /f "tokens=1-3 delims=/ " %%a in ('date /t')  do (set currday=%%a) && (set currmonth=%%b) && (set curryear=%%c)

set currday=23
echo %currday%
set currmonth=4
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 1 (set /a oldmonth=%oldmonth%+12) && (set /a oldyear=%curryear%-1) else set oldyear=%curryear%
if %oldmonth% LSS 10 set oldmonth=0%oldmonth%
echo D:\BACKUP\%oldyear%-%oldmonth%_Week_%currweek%
endlocal