:: krowemoh

Thursday | 26 DEC 2024
Posts Links Other About Now

previous
next

Deleting Files Older than N Days

2024-01-08
sysadmin

A handy little command to delete files. This is for Linux

find /path/to/folder -type f -mtime +30 -delete 

This will delete files older than 30 days in Windows. This also searches through subdirectories through the /s option. The echo is helpful to get some output of what was deleted.

forfiles /p "C:\Folder" /s /m *.log /D -30 /C "cmd /c echo @path && del @path"

forfiles documentation

Notice that the sign is different for the two operating systems. Annoying.