【问题标题】:AppleScript Folder Action - Add Only MP3's from Download folder Automatically to iTunesAppleScript 文件夹操作 - 仅将下载文件夹中的 MP3 自动添加到 iTunes
【发布时间】:2014-03-11 18:15:54
【问题描述】:

我正在尝试创建一个 applescript,它会自动将仅从我的下载文件夹中下载的 MP3 添加为文件夹操作。我在网上找到了以下脚本,它运行良好,除了两件事:每当我从 Internet 下载任何内容时,iTunes 就会启动,并且还会添加 iTunes 愿意从该下载文件夹添加的几乎所有文件。我尝试修改代码大约 15 次,每次 iTunes 没有启动,或者 iTunes 启动任何下载的文件并且不添加文件

原代码为:

on adding folder items to my_folder after receiving the_files
    repeat with i from 1 to number of items in the_files
        tell application "iTunes"
            launch
            try
                set this_file to (item i of the_files)

                add this_file

            end try
        end tell
    end repeat
end adding folder items to 

感谢您的帮助!

【问题讨论】:

    标签: macos applescript mp3 itunes


    【解决方案1】:

    为此,您需要使用 if/then 逻辑来过滤您想要的文件。与此类似的东西(我没有测试,所以语法可能略有偏差)......

    on adding folder items to my_folder after receiving the_files
        repeat with i from 1 to number of items in the_files
            set theCurrentFile to item i of the_files
            if (name extension of (info for theCurrentFile)) = "mp3" then
                tell application "iTunes"
                    launch
                    try
                        set this_file to (item i of the_files)
    
                        add this_file
    
                    end try
                end tell
            end if
        end repeat
    end adding folder items to 
    

    或者,为什么不使用 Automator 来执行此操作?它具有过滤文件的操作和将文件导入 iTunes 的操作。而且,您可以使用它创建一个文件夹操作。请参阅我随附的屏幕截图。

    希望这会有所帮助。

    -本

    【讨论】:

    • 谢谢你!它工作得很好。只有 mp3 可以打开 iTunes,并且它们也会被添加到 iTunes 中。我曾尝试过类似的方法,但它无法正常工作。此外,我没有使用 automator,因为我无法让它完全按照我的意愿去做。再次感谢您的帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-12
    相关资源
    最近更新 更多