bat生成时间和删除文件

windows的

set time_hh=%time:~0,2%

if /i %time_hh% LSS 10 (set time_hh=0%time:~1,1%)

set filename=%date:~,4%%date:~5,2%%date:~8,2%_%time_hh%%time:~3,2%%time:~6,2%

echo test >> %filename%.txt


linux的

#!/bin/sh

echo test >> $(date -d "today" +"%Y%m%d_%H%M%S").txt


windows删除30天前文件

forfiles /p "d:\108" /s /m *.* /d -30 /c "cmd /c del @path"

其中

/m 设置过滤的文件

/p 查找路径

/d 日期


你可能感兴趣的:(bat,删除文件,生成时间文件)