Skip to content

Instantly share code, notes, and snippets.

@staybuzz
Created January 15, 2014 10:30
Show Gist options
  • Save staybuzz/8434019 to your computer and use it in GitHub Desktop.
Save staybuzz/8434019 to your computer and use it in GitHub Desktop.
@echo off
REM 9日前の日付をセットする
set yyyy=%date:~0,4%
set /a ymod=%yyyy% %% 4
set mm=%date:~5,2%
set dd=%date:~8,2%
set /a dd=1%dd%-109
REM 9日前が月を跨ぐ場合の処理
REM 比較演算子"LSS" -> "より小さい"
if %mm%==01 if %dd% LSS 1 (set mm=12&& set /a dd=31+%dd%&& set /a yyyy=%yyyy%-1)
if %mm%==02 if %dd% LSS 1 (set mm=01&& set /a dd=31+%dd%)
if %ymod%==0 (
if %mm%==03 if %dd% LSS 1 (set mm=02&& set /a dd=29+%dd%)
) else (
if %mm%==03 if %dd% LSS 1 (set mm=02&& set /a dd=28+%dd%)
)
if %mm%==04 if %dd% LSS 1 (set mm=03&& set /a dd=31+%dd%)
if %mm%==05 if %dd% LSS 1 (set mm=04&& set /a dd=30+%dd%)
if %mm%==06 if %dd% LSS 1 (set mm=05&& set /a dd=31+%dd%)
if %mm%==07 if %dd% LSS 1 (set mm=06&& set /a dd=30+%dd%)
if %mm%==08 if %dd% LSS 1 (set mm=07&& set /a dd=31+%dd%)
if %mm%==09 if %dd% LSS 1 (set mm=08&& set /a dd=31+%dd%)
if %mm%==10 if %dd% LSS 1 (set mm=09&& set /a dd=30+%dd%)
if %mm%==11 if %dd% LSS 1 (set mm=10&& set /a dd=31+%dd%)
if %mm%==12 if %dd% LSS 1 (set mm=11&& set /a dd=30+%dd%)
set dd=00%dd%
set dd=%dd:~-2%
REM フォルダ形式の名前にあわせる。
set ninedaysago=%yyyy%-%mm%-%dd%
echo %ninedaysago%の番組を削除します。中断する場合はCtrl+Cを押してください。
timeout /nobreak 60
REM 無慈悲な削除
REM 確認なしで9日前のフォルダを削除します。
rd /s /q "Z:\%ninedaysago%"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment