eCarlos.net

eCarlos blogger om .Net, Sharepoint, Umbraco, Hosting og meget mere

using forfiles to delete old directories

forfiles is old, but still a very valid tool when cleaning up on servers. - Just a small tip to get started.

Delete folders older than 4 days

forfiles /p c:\backup\ /d -4 /s /c "cmd /c if @isdir==TRUE echo @file"
(replace echo with rmdir /q /s)

Delete files older than 4 days

forfiles -p "C:\data\backup" -s -m *.* -d -4 -c "cmd /c echo @path"
(replace echo with del)

Loading