Tuesday, April 21, 2015

Find and clean / remove files with a specific pattern in a deep directory tree

If you need to remove all the files that comply to:
* file pattern (eg *Uploads/*.pdf)
* a size constraint (eg >= 50k)
* older than some days before today (eg 365 days older)


find . -wholename *Uploads/*.pdf -size +50k -mtime +365 -print0 | xargs -0 rm

No comments: