Run a script on inserting an audio CD
Preflighting vinyl import was pretty easy, because for vinyl import, I was already using an AppleScript to do the import. However, I have the same problem when importing CDs: if I recently converted a podcast to MP3 mono and forgot to change it back, I’ll end up accidentally importing CDs as low quality mono rather than high quality stereo.
It isn’t that big of a deal, because iTunes will recognize when you re-import a CD you’ve imported before. It will ask if you want to replace the existing files, and if you say yes, it will copy all of the information over to the new, better files: play count, last played, names, ratings, even album cover if you’ve put one onto the tracks.
But it would be nice to get a warning when I’m about to import an audio CD at poor quality similar to the warning I get when I’m about to import vinyl at poor quality. Fortunately, there is an easy way of running our own script whenever we insert an audio CD.
Back when you first got your Macintosh, you might remember that sometimes, on inserting media, the Mac would ask you what you want to do with that media. The Mac then stores your preference for future use. You can reset these preferences in your System Preferences. Choose “CDs & DVDs” from the Hardware row. You can choose one of your scripts for what to do “When you insert a music CD”.
The script must be saved as File Format script, not as an application.
[toggle code]
-
on run
- tell application "iTunes" to set theEncoder to the format of the current encoder
-
if theEncoder is not "AAC" then
- display dialog "iTunes is not set to use AAC"
- return
- end if
- end run
Obviously, if you prefer MP3 you’ll change that as your encoding format. Unfortunately, I can still find no way to check the bit rate.
In response to Preflight iTunes Imports: Once you start using an AppleScript to do automated tasks, you can also more easily preflight those tasks to make sure that everything is okay on all ends.
More AppleScript
- Find all parent mailboxes in macOS Mail
- The macOS Mail app seems to want to hide the existence of mailboxes and any sense of hierarchical storage. These two AppleScripts will help you find the full path to a selected message and open the message’s mailbox.
- JXA and AppleScript compared via HyperCard
- How does JXA compare to the AppleScript solution for screenshotting every card in HyperCardPreview?
- Using version control with AppleScripts
- AppleScripts aren’t stored as text, which makes it impossible to track changes in AppleScript files using version control software such as Mercurial or Git.
- Save clipboard text to the current folder
- Use the Finder toolbar to save text on the current clipboard directly to a file in the folder that Finder window is displaying.
- Adding parenthetical asides to photograph titles on macOS
- Use Applescript to append a parenthetical to the titles of all selected photographs in Photos on macOS.
- 17 more pages with the topic AppleScript, and other related pages
More iTunes
- Catalina vs. Mojave for Scripters
- More detail about the issues I ran into updating the scripts from 42 Astounding Scripts for Catalina.
- Catalina: iTunes Library XML
- What does Catalina mean for 42 Astounding Scripts?
- A present for Palm
- Palm needs a little help understanding XML.
- Getting the selected playlist in iTunes
- It took a while to figure out how to get iTunes’s selected playlist as opposed to the current playlist in AppleScript.
- Cleaning iTunes track information
- Python and appscript make it easy to modify iTunes track information in batches—if you’re willing to get your hands dirty on the Mac OS X command line.
- Five more pages with the topic iTunes, and other related pages