• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: iTunes: any way to delete MP3's based on mod date?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iTunes: any way to delete MP3's based on mod date?


  • Subject: Re: iTunes: any way to delete MP3's based on mod date?
  • From: Sander Tekelenburg <email@hidden>
  • Date: Thu, 15 May 2003 19:28:50 +0200

At 10:50 -0500 UTC, on 5/15/03, Rubin, Jonathan wrote:

> [...] the filename always contains "WXPN".
> I'm quite the AppleScript beginner, so would you mind providing more detail
> as to how to set up the script to delete files that contain "WXPN" in the
> song title and have a modification date > 7 days from today?

The iTunes dictionary tells you which properties a track has. From it, you
can deduct:

-- first define aTrack. For instance:
set aTrack to current track
-- then:
tell application "iTunes"
set modDate to modification date of aTrack
end tell

To compare the result with the current date, you simply subtract the track's
modification date with the current date. The result is in seconds. 86400
sexconds in a day, hence (7 * 86400) for 7 days.

if (get current date) - modDate > (7 * 86400) then
-- aTrack was last modified over 7 days ago
-- do stuff
end if

[Note that this bit is pure AppleScript. No need to have this within an
application's tell block. General rule: when there is no need to embed
something in an application's tell block, don't.]

To loop through a playlist and do the above to all and only tracks containing
"WXPN" in their name:

tell application "iTunes"
-- createa a list of all the tracks in a specific playlist
-- , provided tha track's name contains a certain string:
set theTracks to every track of playlist "my playlist" whose name contains
"WXPN"
-- loop through all the tracks to which the preceding conditions apply:
repeat with aTrack in theTracks
delete aTrack
end repeat
end tell


Putting these bits together into one useful script will be up to you.

Note that while experimenting you may accidentally delete tracks you didn't
want to delete. I'd advice that, until you're sure your that your script
works reliably enough for you, you build in some security mechanism. In the
above repeat loop, do something like this for instance:

tell app "iTunes'
repeat with aTrack in theTracks
display dialog "Really delete \"" & (name of aTrack) & "\"?"
delete aTrack
end repeat
end


HTH


--
Sander Tekelenburg, <http://www.euronet.nl/~tekelenb/>
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Set Window Bounds Parameter Error?
  • Next by Date: Minimize every window
  • Previous by thread: Re: iTunes: any way to delete MP3's based on mod date?
  • Next by thread: [OT] db tercio mysterioso
  • Index(es):
    • Date
    • Thread