问题描述
我想编写一个 AppleScript,它允许我使用给定的库启动 iTunes,而不必按住 Option 键并浏览.我已经知道 Doug 的图书馆经理,这不是我想要的.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 的首选项,在其中存储书签(别名)到当前选择的库(或者什么都没有,如果您在默认位置使用库).
iTunes doesn't allow you to do this with AppleScript, but you can write directly into iTunes' preferences, where it stores a bookmark (alias) to the currently selected library (or nothing, if you're using a library in the default location).
首先,您需要获取所选库位置的别名数据.按住 Option 键打开 iTunes,选择您的资料库并退出 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 'book: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 '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
的行.
Paste the library location between the quotes in the first line of the script, and you should be all set. To return to the original library, uncomment the line including defaults delete
.
这篇关于使用特定库启动 iTunes 的 Applescript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!