frontpage : here

Script FAQ & Solutions

Here are some of the most commonly asked questions I receive. There are several links to informative Apple sites and elsewhere in the right-hand column. Be sure to also browse the iTunes AppleScripts Forum at iLounge. For more general help with iTunes, see Apple's iPod + iTunes Service & Support Page and the iTunes Discussions board.

After upgrading to Mac OS 10.6 Snow Leopard I can't find the Script Editor application. Is it a separate installation?

I require an AppleScript for a particular project. Unfortunately, I know nothing about AppleScript. Can you help me out?

How can I get rid of the Startup Screen that asks me to Run or Quit the script?

What's the difference between a "Plain AppleScript" and a "Universal Binary" and should I care?

Isn't there a way of making AppleScripts run natively on Macs with Intel processors?

Where are the AppleScripts for the Windows version of iTunes?

I really like the way your site shows what you're listening to. Can you share with me how you're accomplishing this?

I followed the instructions for creating a "Scripts" folder in my username > Library > iTunes folder. However AppleScripts don't show up in the iTunes Script menu when I place it in the scripts folder. What am I doing wrong?

StuffIt doesn't seem to be expanding the files I download from your site correctly. I get a lot of weird files.

I deleted a lot of audio files...now I have a lot of tracks labeled with "!". Any easy way to get rid of them?

Wait a sec! I didn't delete any files, but I still see "!" next to some tracks. What gives?

I have a Windows-formatted iPod and I want to move the audio files on it to my Mac...any AppleScript help?

I use the "Re-Add Tracks as Podcasts" script. Is there anyway to group subsequent tracks to a a particular podcast, rather than as a separate podcast each time I run the script?

How can I change the "date added" date of some of my tracks?

I store my music on an external drive. When attempting to use some of your scripts I get a "Can't get <<class psxf>> -1728" error. What's up with that?

I seem to have a lot of duplicates....

Whenever I run an AppleScript I get an error to the effect that certain files are not accessible. By the way, I'm using File Vault to encrypt my home directory.

I'm running a script that interfaces with my iPod. I keep getting an error message like "Can't make path/to/my/iPod into an alias". What can I do?

I'm using a script that requires me to select iPod tracks...but they're all grayed-out. What gives?

I'm getting this error message: "Could not run this script because the required resources were not found. -192". As a result, I cannot run scripts from iTunes' Script menu.

I have some audio books on CD that I want to import into iTunes so I can put them on my iPod. Is there way to make them "bookmarkable"?

How can I set-up my iTunes music library in such a way that all the users on the computer can access the same library?

How can I access the shared tracks on the iTunes of other machines on my network? For instance, I want to copy a shared track from my remote desktop to my local laptop.

I have a single MP3 file of an entire album that I would like to break down into the individual tracks. Is there some way to break up a single MP3 into separate tracks?

I want to transfer my files from my hard drive to an external drive. Is there a script that will help me maintain my meticulously arranged playlists?

What do you know about ID3 Tags?

I'd like to eliminate duplicate files from my audio file collection. Is there an AppleScript solution?

Is there any way to create a sleep/alarm for iTunes using AppleScript?

I want to print out a list of tracks but iTunes' "Export Song List" command is not the most desirable format.

I neglected to "Get CD Track Names" from CDDB when I ripped a CD. Now all the tracks are called "Track 01", "Track 02," etcetera. Is there an easy way to get this data after a rip?

Artist names retrieved from CDDB are most always "First Name Last Name" or "The Something This" and "The Something That". I want to categorize my tracks by using the artist's last name first or by keeping "The" at the end of the name.

The other annoying thing that some of these online databases do is swap the Artist and Track Name info.

I want to write a script that accesses all the information available from CDDB.

I want to rename my tracks' filenames to something like "Track Name - Artist Name" or "Track Name - Artists Name - Album Name".

My MP3 CD player plays back songs in alphanumerical order, not the order I want. How can I burn an MP3 CD and keep MY order of tracks?

I listen to Classical music. When setting my playlists to shuffle, track movements that should be played in order are played out of sequence. How can I shuffle my Classical Library yet keep the tracks together in the correct album order?

 

• After upgrading to Mac OS 10.6 Snow Leopard I can't find the Script Editor application. Is it a separate installation?

No. As of Mac OS 10.6, Script Editor is called "AppleScript Editor" and is located in your /Applications/Utilities/ folder.

 

• I require an AppleScript for a particular project. Unfortunately, I know nothing about AppleScript. Can you help me out?

No, I am afraid I cannot.

 

• How can I get rid of the Startup Screen that asks me to Run or Quit the script?

First of all, I never save scripts using the "Startup Screen" option. Nevertheless, for some reason, the Startup Screen will display by default. I suspect it has something to do with how Leopard handles AppleScripts created in Tiger and before. To prevent the Startup Screen from ever showing again, you must open the script with Script Editor and re-save it with "Save As..." making sure to uncheck the "Startup Screen" option in Script Editor's Save panel. Also, it is very important to make certain that the script's original "File Format" is used; don't save a compiled Script as an Application, and visa versa. Make a note if an Application needs to "Stay-Open".

• What's the difference between a "Plain AppleScript" and a "Universal Binary" and should I care?

By "Plain AppleScript" I mean an AppleScript whose file format is "Compiled" or "Application". The file format of a "Universal Binary" is either "Script Bundle" or "Application Bundle". Both kinds of AppleScripts will run on PowerPC and Intel Macs. However, an Intel Mac will use Rosetta to interpret the "Plain AppleScript"--which renders less than optimum performance--whereas a "Universal Binary" is able to run natively and well within the parameters of performance awesomeness on both PowerPC and Intel Macs. Here is the Wikipedia entry for universal binary.

Most of the AppleScripts for download are "Plain AppleScripts". However, as of March 2008, my intention is to post only "Universal Binary" formats.

There are other advantages to using bundles as well. A bundle can include additional files in its "Resources" folder such as text and .PDF docs, scripting libraries, media files, and so on.

• Isn't there a way of making AppleScripts run natively on Macs with Intel processors?

Yes. You can re-save a "Plain AppleScript" as either a "Script Bundle" if it is currently a "Compiled Script" or as an "Application Bundle" if it is currently an "Application". Bundle-type saves are universal binary.

• Where are the AppleScripts for the Windows version of iTunes?

Sorry, Charlie! AppleScript is Macintosh-only. However, I am trying to keep an up-to-date list of Windows resources. Email me with your info.

(AppleScripts are not like JavaScripts or Perl scripts and cannot be opened in a text editor. AppleScripts can only be created or opened on a Macintosh computer with Script Editor or other AppleScript-writing software.)

• I really like the way your site shows what you're listening to. Can you share with me how you're accomplishing this?

Not as easy as it could be. It's a running experiment. Read more here.

• I followed the instructions for creating a "Scripts" folder in my username > Library > iTunes folder. However AppleScripts don't show up in the iTunes Script menu when I place them in the scripts folder. What am I doing wrong?

Make sure the folder in your username > Library > iTunes folder is called "Scripts". Make sure there are actual AppleScripts inside of it. If you are creating the folder for the first time you may need to quit and restart iTunes; you may even need to 1) log out and log in, or 2) restart your computer. Once the Script menu appears in iTunes, AppleScripts will appear immediately once you add them to the folder.

In addition, iTunes 9.0.2 introduced a presumed bug whereby AppleScript Application Bundles--the default ".app" AppleScript type in Snow Leopard--will not display in the iTunes Script menu. In such instances, you could place an alias to the iTunes "Scripts" folder in your [username]/Library/Scripts/Applications folder; all iTunes scripts will appear in the system-wide Scripts menu in the Menu bar.

• StuffIt doesn't seem to be expanding the files I download from your site correctly. I get a lot of weird files.

Files and folders have been ".zipped" using the Mac OS X Finder's built-in "Create Archive" command. Do not use StuffIt to expand them. You should only have to double-click the .zip file in the Finder to un-zip the downloaded folder. Try this:

  • Select the .zip file in the Finder.
  • Press Command-I or choose "Get Info" from the Finder's File menu. This will open the file's "Get Info" window.
  • Click the triangle next to the "Open with:" section of the "Get Info" window to reveal the options.
  • Click the pop-up menu and choose "BOMArchiveHelper" from the list.
  • If "BOMArchiveHelper" isn't in the list then click "Other...". Navigate to [startup disk]/System/Library/CoreServices/BOMArchivehelper and select it.
  • Optionally, click the "Change All" button to ensure that the Finder opens future .zip files automatically using "BOMArchiveHelper".
  • Close the "Get Info" window.

• I deleted a lot of audio files...now I have a lot of tracks labeled with "!". Any easy way to get rid of them?

Your database is filled with "dead" tracks —the ones whose files are no longer on the local drive, or are inaccessible because the external drive on which they are stored is not mounted, or have been loaded via CD. They display a "!" in the playlist. List MIAs will create a text file listing any information that is retrievable from missing tracks. Then, try using the script Remove Dead Tracks to remove them from an individual playlist. For removing such tracks Library-wide, use Super Remove Dead Tracks. It surveys your entire Library and removes any dead tracks from every playlist.

If the files are located on an external drive, try re-mounting the drive.

However, in some rare cases, these dead tracks' files really are available but iTunes fails to recognize their location. You can either double-click these tracks and let iTunes assist you in re-locating them, or use a script like iTunes Track CPR which attempts to locate dead tracks in your iTunes Library folder using the Artist and Album names. See the next Q below

• Wait a sec! I didn't delete any files, but I still see "!" next to some tracks. What gives?

Some users report that their files are intact, yet on occasion, some files go AWOL...they still exist, but for some reason iTunes can't see them, and the tracks they represent show the dreaded "!". To discover the facts, you can use List MIA's, mentioned above, which will create a list of these tracks; then you can go hunting for them. To re-associate these tracks, you must click on them; iTunes will ask if you want to locate the missing file, and you weave through an Open/Save dialog for each one.

I have read reports of people having success with 1) Repairing Permissions (see your Mac Help) and 2) ensuring that your files are set to "Open with:" iTunes—you set this in a single respresentative file's Get Info box; be sure to click "Change all". This latter solution worked for me when, mysteriously, iTunes failed to recognize older files I had ripped with SoundJam and MACast in OS 9 back in the last century.

I have often been asked: "But my tracks are right there! Can't you write a script that just looks for the files in the Music folder?" It's not that easy. However I did put together iTunes Track CPR. It uses the existing data from a "dead track" to try and locate its file in the Music folder. It is not perfect (except for play counts, tag data will be rescued), but it does work well under most circumstances.

• I store my music on an external drive. When attempting to use some of your scripts I get a "Can't get <<class psxf>> -1728" error. What's up with that?

Bummer. No doubt you are using a script that attempts to access the music files on that drive. I'm guessing that your external drive is not Mac-formatted (eg, it's FAT32 or the like). AppleScript cannot access files on a non-Mac-formatted drive...that I know of.

On the other hand: a Correspondent reported that this error also appeared when he had Spotlight indexing disabled for that drive. When Spotlight indexing was re-enabled, and the drive was eventually indexed, the script--in this case "List Folder Files Not Added"--worked.

• I seem to have a lot of duplicates...

Oh brother.

Don't get me started. Read this first.

• Whenever I run an AppleScript I get an error to the effect that certain files are not accessible. By the way, I'm using File Vault to encrypt my home directory.

File Vault will prohibit Finder AppleScript commands from accessing any files in an encrypted directory. This is a security consideration, since a script could be written that infiltrates your machine to perform various Finder commands (like copy, move, and delete) on your files. I have attempted to update those scripts which use Finder AppleScript commands and replace those commands with "do shell script" UNIX file commands. These sorts of commands do work with File Vault active. But I haven't updated all such scripts. If you are having trouble with a script while File Vault is active, let me know.

• I'm running a script that interfaces with my iPod. I keep getting an error message like "Can't make path/to/my/iPod into an alias". What can I do?

Is it possible that your iPod is formatted for Windows? Windows uses a different file format which AppleScript cannot read. See the next Q below

• I have a Windows-formatted iPod and I want to move the audio files on it to my Mac...any AppleScript help?

I'm afraid not. AppleScript cannot access a Windows-formatted hard drive, such as a Windows-formatted iPod. Your best bet is to get the files off of the iPod and into a Windows box (I do not know how or if this is possible--sorry) and then move the files to your Mac—via media or network—and reload them to a Mac-formatted iPod.

• I use the "Re-Add Tracks as Podcasts" script. Is there anyway to group subsequent tracks to a a particular podcast, rather than as a separate podcast each time I run the script?

iTunes maintains the organization of podcasts based on their URL, the link you subscribe to. Additional episodes will be associated with that URL and therefore placed in the same podcast "folder"--if you will.

The script *cannot* maintain the faux-RSS feeds it creates. Therefore, even if you add related files (episodes) they will not appear with their earlier-added siblings because the RSS feeds they were imported from are different.

I am working on an app that *can* maintain RSS feeds locally, but it is not even ready for beta testing yet.

• How can I change the "date added" date of some of my tracks?

You can't. The date added property of track is read-only and cannot be manipulated by AppleScript--or any simple means I am aware. iTunes appears to manage these dates internally and if tracks are re-added iTunes will update date added.

If you need a more reliable date tag, I suggest using the Comments field. This field is generally more stable and "travels" with a file's ID3 Tag data--files that have ID3 Tag data anyway. The Script Append to Selected Tag will enable you to add user-text (such as a date) to the beginning or ending of a selected tag in a selection of tracks.

• I'm using a script that requires me to select iPod tracks...but they're all grayed-out. What gives?

You have your iPod Preferences set to auto-sync so that you cannot access the iPod tracks by selecting them. Go to the iPod's Summary screen and check the box next to "Manually manage music and videos".

Additionally, to prevent iPod from automatically updating when you connect it to your computer, hold down the Command-Option keys as you connect the iPod to your computer (hold the keys down until the iPod appears in the iTunes Source list). This information is from iTunes Shortcuts via iTunes Help Menu.

• I'm getting this error message: "Could not run this script because the required resources were not found. -192". As a result, I cannot run scripts from iTunes' Script menu.

Here's the backstory: In late 2005, I began re-packaging downloads as .dmg files (specific info about this is here). Each .dmg contains the featured script, a Read Me for the featured script, and any other necessary files. It also includes a simple "Installer" droplet, which installs the files in your [username]/Library/iTunes/Scripts folder, creating the "Scripts" folder if necessary. Unfortunately, the first version of the "Installer" droplet did not copy some applications properly. Specifically, it would erroneously copy only the "Contents" folder of some bundled applications. Thus, if a script needed to access one of these applications it would be unable to, and thus "the required resources were not found".

I have since fixed the "Installer". However, if you were one of the unlucky visitors who downloaded and installed a script with the "bad Installer"--not all scripts were affected--then you will always get this error no matter what script you run!

The solution: go to your [username]/Library/iTunes/Scripts folder and delete the "Contents" folder that is probably there. Then, download and install the affected script again. As far as I know, the only script packages that contained a bundled application that was affected by "bad Installer" are: Corral All Dupes, Import iPod Audio Files, Export Artwork to iPhoto, and Backup Purchased Music. If you are getting the error and have downloaded one of these scripts then you need to delete the "Contents" folder, as I described above, and then re-install the script.

I apologize for this inconvenience and gross oversight on my part.

• I have some audio books on CDs that I want to import into iTunes so I can put them on my iPod. Is there way to make them "bookmarkable"?

Yes. Import the tracks on the CD using iTunes AAC encoder. Then, use the script Make Bookmarkable to change the file type of the tracks' files to "m4b "; this will make them "bookmarkable". (Note this side-effect: when files are converted to this file type, they will be listed in iTunes as "Protected AAC". However, this is merely the way iTunes displays the tracks by virtue of seeing them as "m4b" files. The tracks are not protected if you ripped them yourself.)

Note that just changing the files' extensions to "m4b" is not enough. The actual file type (an internal property of the file) must be edited. That's what Make Bookmarkable does.

Another method that I have heard of is to use iTunes "Join CD Tracks" feature (via the Advanced Menu) on the CD tracks, and then running the Make Bookmarkable script.

Additionally, you may want to import your CD tracks using the script Audiobooker whose features include multiple CD support, intelligent track ordering and user-editable track naming.

• How can I set-up my iTunes music library in such a way that all the users on the computer can access the same library?

Paul Withey explains how to do that for iTunes and iPhoto in the article Share Libraries Among Multiple Users on the Same System.

Also, have a look at Six Great Tips for Homemade Dot Mac Servers by Alan Graham at O'Reilly's MacDevCenter.

• How can I access the shared tracks on the iTunes of other machines on my network? For instance, I want to copy a shared track from my remote desktop to my local laptop.

Apple gaveth and then tooketh away. Version 4.0 of iTunes allowed access to shared tracks; version 4.0.1 limited access. However, you can—with the proper network cred and a little AppleScript figgerin'—get access to shared tracks on another machine by simply using the available properties of shared track and comparing those properties to the tracks on a remote machine's iTunes to locate that track (and, consequently, its file) so you can copy it across the network. Try Remote Management Scripts v1.0.

The article Access iTunes On A Remote Machine explains how to do it as well, and some ways of manipulating track data of the remote machine's iTunes tracks. Remember, don't steal music.

• I have a single audio file of an entire album that I would like to break down into the individual tracks. Is there some way to break up a single file into separate tracks?

We have two scripts here that will offer simple help. Copy as MP3 from Start to Stop will encode a copy of the selected track as an MP3 from the Start time to the Stop time. By setting the Start and Stop times to "chunks" of the track, you can slice up an MP3. This method works great on CD tracks especially. If you attempt to encode a copy of an MP3 file make sure your encoder is set at the same bit rate so you don't lose more audio—even so, results may not always be what you expect. The script Player Position to Start or Stop sets either the Start or Stop time to whatever time the track is paused at (you would otherwise have to manually enter the times in the Get Info window), thus making your chop session a little quicker

If that's too lo-tech, then I recommend using another application to edit the audio file. The one I like is a shareware audio editor called Amadeus II. It's also great at converting sound files and doing other effects. You can find it via Version Tracker.

Of course, there are many other popular audio editors available that range in price and features.

• I want to transfer my files from my hard drive to an external drive. Is there a script that will help me maintain my meticulously arranged playlists?

You can do this easily (and intuitively, I might add) with iTunes already: create a folder on the external drive and then change the Music Folder Location in iTunes Preferences > Advanced panel to that new folder. Now click on the "Consolidate Library..." option under the Advanced Menu. iTunes will then copy all your music to that new location (you may want to go out for coffee). All tracks should resolve correctly with playlists intact. The files in the original location can be deleted. Most people are successful and content with this method, even though it might be necessary to spend a short amount of time mopping-up stray tracks afterwards, so you may want to try Restore Lost Track Names.

Apple has posted this Knowledge Base article, "Moving your iTunes Music folder", which describes how to create a new folder in a new location while keeping tag info intact.

The script package Tags to Get Info Comments (and Back) are two scripts which store, and then later retrieve, tags to a track's file's "Get Info" comments. Optionally, you can also store the Playlist names the track appears in, and later restore the track to those playlists which will be recreated if necessary. Supports MP3, AAC, AIFF, and WAV track/files.

ALSO: Here is an excellent hint at Mac OS X Hints from David Bonde concerning the Relocation of a non-standard iTunes library structure. Essentially, the author describes a method by which you can safely move your audio files from one drive to another without losing critical track data, like play count. We get this question asked here a lot and the hint explains the procedure thoughtfully and succinctly.

• What do you know about ID3 Tags?

Everything I know is written right here.

• I'd like to eliminate duplicate files from my audio file collection. Is there an AppleScript solution?

Maybe.

The difficulty with AppleScripting a procedure like this is that there is no way to determine if two files sound the same. While an AppleScript can easily identify duplicate tracks (two or more tracks spawned from the single file) by their database id (an AppleScript property of each track), AppleScript cannot ascertain that two files have the same "sound", even if they have the same names, sizes, bit rates, etcetera. You have to listen to them.

That being said...

The script Trash Duplicates assists in removing duplicate tracks and their files by allowing you to listen to the suspect files.

Wrangle Same-Named Tracks will look for other tracks that contain the same name as the selected track and copy them to a new playlist.

On a grander scale, Corral All Dupes traverses your entire main library or iPod library looking for dupes with the same song name and size and then copies them to a "Dupes" playlist. Once you have them corralled, you can decide which ones are actually duplicates. Also, a newer script, Corral iTunes Dupes examines your iTunes Music Library.xml file using Perl routines to quickly locate dupes and put them in a discrete playlist. As of iTunes 4.7 you can use the "Show Song Duplicates" menu command under the Edit menu. See "Keyboard Shortcuts" under iTunes' Help Menu for track and file Delete-key shortcuts.

My application Dupin may also be of interest to you.

Read this as well.

• Is there any way to create a sleep/alarm for iTunes using AppleScript?

Start iTunes...When? is a very basic countdown script that will start iTunes within a 24-hour period. Street Spirit Fade Out fades iTunes and stops playing after a length of time that you specify. You can't script the sleep function in OS X, but for OS 9 there is Wake From Sleep and Play. Apple's desktop calendar app iCal can be modified to schedule AppleScripts and you can read how to Schedule iTunes AppleScripts With iCal (pre iCal 1.5.1) and iTunes Scripts for iCal ; both of these primers include a simple method for creating an alarm-clock type script.

• I want to print out a list of tracks but iTunes' "Export Song List" command is not the most desirable format.

Have a look at our Exporting Info scripts.

Also, I recommend the application iTunes Publisher.

• I neglected to "Get CD Track Names" from CDDB when I ripped a CD. Now all the tracks are called "Track 01", "Track 02," etcetera. Is there an easy way to get this data after a rip?

Have a look at the Script Get CDDB Track Names. It will import the track names, album name, and artist to your playlist from the CDDB page you have manually located in Internet Explorer. CDDB Safari Kit works similarly with Apple's Safari browser.

By the way, CDDB info is only available to licensed applications, like iTunes. So except for parsing the CDDB HTML pages, as the scripts mentioned above do, there's no other way for non-licensed users to get the extensive data CDDB contains.

• Artist names retrieved from CDDB are most always "First Name Last Name" or "The Something This" and "The Something That". I want to categorize my tracks by using the artist's last name first or by keeping "The" at the end of the name.

We have a script called Artist to "Last, First" that can make some of those changes. For example, "Billy Joel" is changed to "Joel, Billy" and "The Crystal Method" becomes "Crystal Method, The".

Also, check out the complete Managing Track Info category of scripts for many other tag editing scripts.

• The other annoying thing that some of these online databases do is swap the Artist and Track Name info.

You'll want to Swap Track Name & Artist back to their proper positions. I also wrote a set of scripts called This Tag, That Tag Scripts, which enable you to perform various copying, appending and swapping of text between your choice of two types of tags (Song Name, Artist, Album, Composer, Comments, and sometimes Genre) in a batch of selected tracks.

• I want to write a script that accesses all the information available from CDDB.

The Gracenote CDDB proper is not accessible without paying a licensing fee. The only way Us Regular Folks can access any of the information from the database is either via an application whose developer has paid the licensing fee (iTunes from Apple, for instance), or by picking and pruning info from Gracenote's website using HTML parsing scripts like Get CDDB Track Names and CDDB Safari Kit. The best they can do is assist you in your searching and cutting and pasting from CDDB web pages Gracenote makes available. You can't, for example, get BPM, musician, producer, or stuff like that.

• I want to rename my tracks' filenames to something like "Track Name - Artist Name" or "Track Name - Artists Name - Album Name".

There are two scripts that do this very well: File Renamer and Rename File (the latter is based on the former and is further developed) that enable you to rename filenames based on your selection of various track tag data. Track Names to Filenames also copies the selected track's names to the corresponding files.

• My MP3 CD player plays back songs in alphanumerical order, not the order I want. How can I burn an MP3 CD and keep MY order of tracks?

iTunes 3 has an option to import tracks with the play order number. Otherwise, and for iTunes 2, the script Track Names to Filenames has an option to prefix the play order number to your tracks' filenames, thus ensuring they play in order after being burned to CD.

• I listen to Classical music. When setting my playlists to shuffle, track movements that should be played in order are played out of sequence. How can I shuffle my Classical Library yet keep the tracks together in the correct album order?

iTunes 3 allows you to shuffle by Album under the Advanced tab in Preferences. However, for iTunes 2, Random Classical will shuffle your Library and playback albums in the correct track order.

This column is printer-friendly.
Site contents © 2001 - 2010 Doug Adams and weblished by Doug Adams, dougscripts AT mac DOT com.
All rights reserved. Legal.
AppleScript, iTunes, and iPod are registered trademarks of Apple Inc.
Image 01 Image 01 Image 01 Image 01 Image 01 Image 01 Image 01 Image 01 Image 02 Image 03 Image 03 Image 03 Image 03