Categories
Unix Notes

mtime in find

find /users-files/Music -mtime 7 -exec rm “{}” ;

I’d like to write a script that will delete MP3’s in iTunes if their
modification date is greater than 7 days from today. Is this possible? (I
record a radio broadcast everyday & I’d like to have a script that I can run
to delete recordings older than a week.)

This shell command would come close…

find /users-files/Music -mtime 7 -exec rm "{}" ;

Just replace “/users-files/Music” with the appropriate path to your iTunes library.

I have “escaped” the semi-colon because my shell (bash) wants it that way.

This shell command

man find

makes for fascinating reading.

Oh, yeah, I assumed you meant for OS X. Everyone runs OS X, right?