dougscripts.com

Managing Tracks

November 29 2013 - 12:12 pm

UPDATED: Copy Tracks to Multiple Playlists v2.2

Copy Tracks to Multiple Playlists v2.2 will copy the selected iTunes tracks to one or more chosen playlists.

This latest version makes some tweaks for compatibility with OS X 10.9.

More info and download here.

November 6 2013 - 8:18 am

Add Files in Reverse, Sort by Date Added

A Correspondent writes that he sorts his Music library playlist by Date Added and meticulously adds each new album's worth of files to iTunes in reverse order—one file at a time—so that an album will appear in order (well, the order established for them in the Finder); older tracks appear sorted lower in the Music library playlist than newer tracks. Get me?

Predictably, Our Correspondent is dismayed by the drudgery of this method and inquires if AppleScript can provide any relief. AppleScript provide relief from drudgery? Ahoy!

tell application "Finder"

set selectedFiles to selection

repeat with i from (length of selectedFiles) to 1 by -1

my addFile(item i of selectedFiles)

delay 1

end repeat

end tell

to addFile(aFile)

tell application "iTunes"

try

add aFile as alias

end try

end tell

end addFile

Save this as a Script Bundle—named whatever you like—to your ~/Library/Scripts/ folder. This will make the script available in the system-wide Scripts menu at the right side of the menu bar. Select the files in the Finder you want to add, which have been sorted in the order you want, and launch the script. It will add the files to iTunes in reverse order so that when they are sorted by Date Added in iTunes they appear in the order you had for them in the Finder.

UPDATE November 11, 2013: Added 1 second delay in repeat loop to prevent tracks from having the same date added (to the second) and sorting arbitrarily.

October 17 2013 - 7:27 am

UPDATED: Track Down Purchases v2.2

Track Down Purchases v2.2 will examine each track in the entire iTunes library—or a selection of tracks—for items purchased from the iTunes Store (audio, video, and books) and then sort them by either the purchaser's name or account ID into discrete playlists, eg: "Purchased by Tom Ryan" or "Purchased by tomryan@email.com".

This latest version changes the name of each playlist created (prefixing it with "Purchased by") so that they'll sort together and also fixes an issue with misreading account ID data that produced garbled text in the playlist names.

More info and download here.

January 30 2013 - 9:52 am

NEW: Search Results to Playlist

I've been using a variation of this search script for a while so I thought I'd update it with some customization settings nailed on and post it (there's a simple snippet version of it here). The thing is: I often want my iTunes search results to go directly to a playlist so I can get right to work on them there, usually tag editing. Without some automation this is typically a multi-stage grind comprised of searching, selecting track results, making new playlist, naming new playlist, locating and selecting the tracks again when new playlist gets focus (stab!), putting tracks into playlist by any one of various means, and then forgetting why I was searching for these tracks in the first place. (Related memory-loss issue: Name New Playlist From Selection.)

Search Results to Playlist puts a floating window over iTunes that provides the ability to search iTunes and copy the track results to a designated Results Playlist.

It can search the entire library, the selected playlist, or any of the categories (Music, Movies, Books, etc) for text in All, Name, Artist, Album, or Composer tags and then copy the results to a playlist. The script will create this Results Playlist if necessary. If the playlist already exists then the track results can replace its current contents or may be appended to it.

more

November 9 2012 - 8:27 am

NEW: Dual-Pass Search

Dual-Pass Search conducts a two-pass search for tracks in the currently selected playlist. On the first pass, the search query behaves like iTunes' own searchbox. Then the track results from the first pass are processed with a second search query.

The track results can be displayed in a Results Window and optionally sent to Results Playlist in iTunes.

Download it here.

October 20 2011 - 10:23 am

UPDATED: Track Down Purchases v2.0

If you have been making purchases from the iTunes Store using several names or account names then maybe you'll have noticed that there's no easy way to sort purchased tracks by the name or account name used to make the purchase. Oh, wait a minute. Yes there is.

Track Down Purchases v2.0 will examine each track in your entire iTunes library—or a selection of tracks—for items purchased from the iTunes Store (audio, video, and books) and then sort them by either the purchaser's name (the "Purchased by" entry in a track's Get Info Summary tab) or account ("Account Name") into discrete playlists.

This latest version is written as a Cocoa-AppleScript applet for OS 10.6 or 10.7 only, adds the ability to sort by account name, and provides a progress indicator. (My thanks to Correspondent Andrew Wynn Rouse for inventing the account name search portion.)

July 25 2011 - 11:43 am

UPDATED: Remove n Characters from Front or Back v4.0

Remove n Characters From Front or Back v4.0 helps you delete a specified number of characters from either the beginning or the ending of the Song Name, Album, Artist, Comments, Composer or Show tag (or their "Sort" siblings) of each selected track. For example, delete the initial digits and the space from "01 First Track", "02 Second Track", and so on.

This latest version is written as a Cocoa-AppleScript Applet and can only run in OS X 10.6 or 10.7. As you can see from the pic above, it consolidates all settings into a single window and provides an example that is updated as the settings are changed. Text between the arrows would be removed.

December 28 2010 - 1:19 pm

Get a Track Reference from a File Path

Correspondent Wayne B. recently wondered if there is a way to get a reference to a track in iTunes based on its file path. Well, unfortunately, you can't do something like this:

tell application "iTunes"
	set trackRef  to (get some file track of library playlist 1 whose location is "some/file/path.ext")
end tell

That will generate an error. But you can trick iTunes into giving you the track reference by using the add command--if you are certain the file is already in iTunes' database. When you add the file iTunes will check its database for the the corresponding library track for you and if it exists will give up the reference--and it won't re-add it:

set theFile to choose file
-- or however you get the file path

tell application "iTunes"
	try
		set trackRef to (add theFile as alias)
		tell trackRef
			log (get name)
			# and so on...
		end tell
	end try
end tell


But remember that if the file isn't already in iTunes' database then iTunes will add the file as a matter of course, which may not be what you want. So this trick may work best only when you know a file is currently in your library.

You will not want to use the open command instead of add, because open will compel iTunes to play the file in addition to any add-housekeeping.

November 29 2010 - 10:49 am

Library Benefits

A Correspondent observes that PDFs and digital booklets are no longer lodged in the "Music" library but in the "Books" library. Thus he laments that he is unable to access these books alongside the music tracks while browsing the "Music" library. While book-type tracks and music tracks can reside in the same playlist, yes, they do belong to different libraries. But creating a separate playlist for every album with a PDF or digital booklet doesn't seem very efficient.

I used Change Hidden iTunes Preferences to toggle the visibility of the "Library" library playlist. In the pic below it is listed atop the other library playlists. In the old days, this was the main library playlist and listed everything in the library. Well, it still does. When the "Library" is available, you can use the Column Browser to access an entire Album, which will include any associated booklet (providing the Artist/Album tags correspond correctly):

(The yellow highlight over the booklet is an artistic representation.)

June 10 2010 - 2:03 pm

NEW: Report Real Play Time

Correspondent Jamie Shaw sent me a version of a script that calculates the play time of selected tracks or tracks in a playlist when the user-set Start and Stop times are also accounted for. In such cases, the total play time (for a playlist) would be shorter than what is displayed along the bottom of the playlist. I threw in a routine that lets you enter your Crossfade time (not really accessible programatically) and this is also part of the calculation. Report Real Play Time works especially nice when assigned a keyboard shortcut.

Site contents © 2001 - 2024 (that's right: 2001) Doug Adams and weblished by Doug Adams. Contact support AT dougscripts DOT com. About.
All rights reserved. Privacy.
AppleScript, iTunes, iPod, iPad, and iPhone are registered trademarks of Apple Inc. This site has no direct affiliation with Apple, Inc.
The one who says "it cannot be done" should not be interrupting the one who is doing it.