The Web as filtered (and hopefully enriched ;-) by Adrian McEwen

Delete reworked

I’ve revamped the way that “deleting” songs works on NewMusicRadio. Now the “deleted” songs are just added to a list of files to exclude, and the original files are left as-is.

This means that:<ol><li>The $deleteFilter is deprecated because none of the mp3 files are actually harmed when “deleted”</li><li>I can decide I don’t like tracks that came on CDs without ending up with random tracks in my music collection being deleted (even if they aren’t tracks I like)</li><li>Most importantly, you don’t need the --ignore-length switch on wget anymore</li><li>You also don’t need the chmod g+w because the script doesn’t have to overwrite files</li></ol>

I’ve added a few lines of statistics output to my cron script because I’m curious as to how many files drop off the list as “too old” each day, and how many new files are added. These are the extra find and wc lines.

The final big change is with the line: find /home/tunes/downloads/ -name \*.mp3 -mtime +42 -exec rm {} \;

This deletes any mp3s older than 42 days in the directory /home/tunes/downloads/ (or any directories below that). In detail:

  • /home/tunes/downloads/ this is the directory where all my downloaded (mp3 blogs and Soulseek) mp3s live
  • -name \\*.mp3 find should only look for files called <something>.mp3
  • -mtime +42 only look for files older than 42 days. The + is important, -42 means look for files younger than 42 days
  • -exec rm {} \\; for each file found, perform an rm <filename>; to delete it

There’s still more to play with to link the mp3s downloaded from mp3 blogs to their source, but I think the bare bones of it are now working correctly.

This page is part of Adrian McEwen's blog, McFilter. Explore more in the category pages or archives below.

Subscribe to updates with the RSS feed (what's an RSS feed?)