【问题标题】:Transfer Music file from USB into "Automatically Add to iTunes" and play it with Applescript将音乐文件从 USB 传输到“自动添加到 iTunes”并使用 Applescript 播放
【发布时间】:2017-03-13 02:09:55
【问题描述】:

我需要一个脚本,将音乐文件从我的 USB 音乐文件夹移动到“自动添加到 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 中“音乐”下的文件传输到“自动添加到 iTunes”中,然后启动 iTunes,播放那个音乐文件。

【问题讨论】:

    标签: macos usb applescript itunes


    【解决方案1】:

    你可以用这个:

    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 文件夹:)

    【讨论】:

    • 谢谢。唯一的问题是我不知道怎么写。假设“自动添加到 iTunes”在“Macintosh HD”中的“MyName”中的“音乐”中的“iTunes”中的“iTunes 媒体”中。我该怎么写?另外,将那个文件以艺术家文件夹、专辑文件夹和文件的形式移动到iTunes“音乐”中会更容易吗?
    • 我已经更新了答案,以反映你如何去做——另一个选择是你也可以提示用户输入一个文件夹(以防你更换 USB?)。至于在 iTunes 中播放歌曲,我不太确定,但也许您可以尝试寻找一种方法来查看最近添加的歌曲,然后播放?
    • 如果我已经回答了您的问题,您可以将其标记为答案吗?谢谢:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-13
    • 1970-01-01
    • 1970-01-01
    • 2017-05-13
    • 2014-05-03
    • 1970-01-01
    相关资源
    最近更新 更多