将音乐文件从 USB 传输到 "Automatically Add to iTunes" 并使用 Applescript 播放

Transfer Music file from USB into "Automatically Add to iTunes" and play it with Applescript

我需要一个脚本,将音乐文件从我的 USB 音乐文件夹移动到 "Automatically Add to iTunes" 文件夹,然后播放该文件。这是我目前所拥有的:

tell application "Finder"
move items from "LEXAR:Pictures:Music:" to "Macintosh HD:User:" --this is where i'm lost, i need the path that doesnt include my name as the User
--and i need some way to tell itunes to play that file

抱歉奇怪的代码设置。我想要发生的是我将我的 USB 插入某人的计算机,单击此脚本作为 .app,它会将我 USB 中 "Music" 下的文件传输到 "Automatically Add to iTunes",然后启动 iTunes,播放那个音乐文件。

你可以使用这个:

tell application "Finder"
    set userPath to (path to home folder as text)
    set directoryPath to "Music:iTunes:iTunes Media:Automatically Add to iTunes"
    set fullPath to userPath & directoryPath
    move every file of folder "LEXAR:Pictures:Music:" to folder fullPath
end tell

然后使用该变量获取当前登录用户的主文件夹。从那里,您可以参考自动添加到 iTunes 文件夹:)