Write-protect your iTunes library to avoid accidental deletion or damage
by, 07-17-2014 at 11:47 AM (1152 Views)
Here are two AppleScripts that turn write-protection on and off for your music library. If you want to add or edit stuff, run the script ResetWriteProtectMusic. If you want to protect your music files from accidental alteration or deletion, run the script WriteProtectMusic. These can be placed in the user's ~/Library/iTunes/Scripts directory, and they appear in the iTunes script menu item (here as the bottom two entries):
The AppleScripts (Updated for 10.11 and iTunes 12.3, should be back-compatible):
The scripts assume a normal iTunes-organized music library, but you can alter them easily enough if your situation is non-standard.
It is designed to "just work" for a standard iTunes library, regardless of where you have it located.
Here is how this is discovered:
The first line contains a line of unix code (embedded as an Osascript) that looks like this:
It reads the iTunes library XML file to find where you keep your music. On my iMac, it returns this:Code:defaults read ~/Library/Preferences/com.apple.iApps.plist iTunesRecentDatabases | grep file | perl -p -e 's|file://localhost||g' | perl -p -e 's|iTunes%20Music%20Library.xml||g' | perl -p -e 's|iTunes%20Library.xml||g' | perl -p -e 's| \"||g' | perl -p -e 's|\"||g'
and on my mac mini, it returns this:Code:/Users/wgscott/Music/iTunes/