AppleScript的推出的iTunes与特定库 [英] Applescript to launch iTunes with a specific library
问题描述
我想编写一个AppleScript,让我来发动,而不必按住一Option键和浏览具有给定库的iTunes。我已经知道道格的图书馆经理,这是不太我想要什么。该AppleScript的将是一个特定库。
I would like to write an AppleScript that would allow me to launch iTunes with a given Library instead of having to hold down the Option key and browsing for one. I'm already aware of Doug's Library manager, which is not quite what I want. The AppleScript would be for a specific library.
推荐答案
iTunes不能让你与AppleScript的做到这一点,但你可以直接写入到iTunes'preferences,其中存储的别名目前所选库(或没有,如果你使用的默认位置的库)。
iTunes doesn't allow you to do this with AppleScript, but you can write directly into iTunes' preferences, where it stores an alias to the currently selected library (or nothing, if you're using a library in the default location).
首先,你需要获得别名数据为您所选择的库的位置。打开iTunes按住Option键,选择您的图书馆和退出iTunes。然后,在终端,运行:
First, you'll need to obtain the alias data for your selected library location. Open iTunes holding down the Option key, select your library and quit iTunes. Then, in Terminal, run:
defaults read com.apple.itunes 'alis:1:iTunes Library Location' | pbcopy
这将图书馆别名数据复制到剪贴板。
This will copy the library alias data to the clipboard.
最后,这里的脚本:
property otherLibraryLocation : "" -- paste location between the quotes
property libraryLocationPref : "com.apple.iTunes 'alis: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
在脚本的第一行粘贴引号之间的库的位置,你应该准备就绪。要恢复到原来的库,取消包括默认的行删除
。
这篇关于AppleScript的推出的iTunes与特定库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!