SQLCMD.exe -S localhost -U [ID] -P [PW] -d [DB] -i [D:\BatchFiles\query.sql] -s, -W -h -1 -o [D:\LogFiles\log.txt] <日付> %date:~0,4%%date:~5,2%%date:~8,2% <時間> set time2=%time: =0% %time2:~0,2%%time2:~3,2%%time2:~6,2% <古いファイルの削除> C:\Windows\System32\forfiles /p C:\BackupFiles\data /d -10 /m "*.bak" /c "cmd /c del @file" <ファイルのサイズ確認> for %%I in ( D:\data\Qutput.csv ) do set size=%%~zI if %size% gtr 0 [サイズが0じゃなかった時のコマンド] <ファイルの存在確認> if exist D:\data\Qutput.csv ([ファイルがあった時のコマンド])