How Can I Delete Files From My Trash Older Than x Months

Just want to see what will be deleted?:

find /Users/username/.Trash/* -mtime +730 -print

Actually delete the files (This can’t be undone):

find /Users/username/.Trash/* -mtime +730 -exec rm -f {} \; 

Keep in mind, you must substitute ’username’ with your actual username.

find/Users/username/.Trash/* finds all the files in the given directory

-mtime +730 finds files modified greater than 730 days ago.

-print prints the files found to the output (shell screen)

-exec rm -f {} \; executes the command rm with -f flag to force on the file found {}. \; stops the command.

Tested and working 5/1/09 on OS X 10.5.6

Rate This Article:
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading ... Loading ...

Leave a Comment

You must be logged in to post a comment.