2012/11/09

Batch delete of old files

May have already noted this somewhere. Using find, xargs, and modification time to delete old files.

find . -ctime +364 -print0 | xargs -0 rm -rf

In this case, we're deleting files older than 364 days old. The print0 is needed along with the -0 option on xargs to deal with weird characters in the file names (spaces, special characters, etc).

Use the -atime flag to find files based on last access time.