我想编写一个AppleScript,允许我使用给定的库启动iTunes,而不必按住Option键并浏览一个。我已经知道了Doug的图书馆经理,这不是我想要的。 AppleScript将用于特定的库。
答案 0 :(得分:12)
iTunes不允许您使用AppleScript执行此操作,但您可以直接写入iTunes的首选项,它会将书签(别名)存储到当前选定的库中(如果您使用的是库,则不会显示任何内容)默认位置)。
首先,您需要获取所选库位置的别名数据。打开iTunes按住Option键,选择您的库并退出iTunes。然后,在终端中,运行:
defaults read com.apple.itunes 'book:1:iTunes Library Location' | pbcopy
这会将库别名数据复制到剪贴板。
最后,这是脚本:
property otherLibraryLocation : "" -- paste location between the quotes
property libraryLocationPref : "com.apple.iTunes 'book:1:iTunes Library Location'"
-- first, quit iTunes if it's running
tell application "System Events"
if exists (application process "iTunes") then
tell application "iTunes" to quit
end if
end tell
-- then, set the location
do shell script "defaults write " & libraryLocationPref & " " & quoted form of otherLibraryLocation
-- uncomment the following line to use the default iTunes library instead
-- do shell script "defaults delete " & libraryLocationPref
-- finally, relaunch iTunes
tell application "iTunes" to activate
将库位置粘贴到脚本第一行的引号之间,您应该全部设置。要返回原始库,请取消注释包括defaults delete
。
答案 1 :(得分:3)
您可以在unix shell脚本(man ln)中创建从〜/ Music / iTunes到所选目录路径的符号链接。 AppleScript可以通过向终端应用程序发送相应的消息来调用unix shell脚本。