windows batch file to delete folders older than x days

# 發現這個東西常常會用到可是老是忘了指令…

forfiles /p "D:\Programmi Installati\" /d -1 /c "cmd /c if @isdir==true echo rd /s /q @path"

# 另一種指令刪某名字開頭

forfiles /p "D:\Programmi Installati\" /m "log_*" /d -1 /c "cmd /c if @isdir==true echo rd /s /q @path"

# Linux

find /path/to/directory/ -mindepth 1 -mtime +5 -delete -type f

find /var/log -name "*.log" -type f -mtime +30 
find /var/log -name "*.log" -type f -mtime +30 -delete 

# 目錄
find /var/log -type d -mtime +90 
find /var/log -type d -mtime +30 -exec rm -rf {} \; 

發佈留言