将新文件添加到iTunes播放列表的Applescript文件夹操作

将新文件添加到iTunes播放列表的Applescript文件夹操作,applescript,dropbox,itunes,Applescript,Dropbox,Itunes,我正在尝试为dropbox文件夹创建一个applescript,这样当一个新文件添加到该文件夹时,它会自动将该文件添加到iTunes中的特定播放列表中(目标是只需将一个文件添加到一个dropbox文件夹中,即可远程更新多台计算机的播放列表) 除了将文件添加到iTunes播放列表中外,applescript可以正常工作。调试有点棘手,因为它是一个文件夹操作,所以无法在脚本编辑器中运行。我一直在使用“显示对话框”试图了解正在发生的事情,但对话框显示的信息对我来说似乎是正确的,所以我很困惑。非常感谢您

我正在尝试为dropbox文件夹创建一个applescript,这样当一个新文件添加到该文件夹时,它会自动将该文件添加到iTunes中的特定播放列表中(目标是只需将一个文件添加到一个dropbox文件夹中,即可远程更新多台计算机的播放列表)

除了将文件添加到iTunes播放列表中外,applescript可以正常工作。调试有点棘手,因为它是一个文件夹操作,所以无法在脚本编辑器中运行。我一直在使用“显示对话框”试图了解正在发生的事情,但对话框显示的信息对我来说似乎是正确的,所以我很困惑。非常感谢您的帮助

我尝试过使用POSIX路径,我尝试过将项设置为别名,作为字符串,我尝试过将项设置为另一个带有“\”&item&“\”的变量


除非在警报对话框中使用
try
语句,否则文件夹操作将以静默方式失败。在您发布的示例中,将
display dialog
与别名一起使用,而不是首先将其强制为字符串,会出现错误

我发现,通过将功能分解为自己的处理程序,并添加
run
open
处理程序,脚本可以在脚本编辑器中测试和运行,或者作为小程序/小程序运行,此外还可以用作文件夹操作,例如:

property playlistToUpdate : "Public News Service"

on run -- applet or from the Script Editor
    doStuff for (choose file with multiple selections allowed)
end run

on open droppedItems -- droplet
    doStuff for droppedItems
end open

on adding folder items to theFolder after receiving theNewItems -- folder action
    doStuff for theNewItems
end adding folder items to

to doStuff for someItems -- the main stuff
    set filesAdded to {}
    repeat with anItem in someItems
        tell application "iTunes"
            launch
            delay 2
            display dialog (anItem as text)
            add anItem to playlist playlistToUpdate
        end tell
    end repeat
end doStuff

谢谢你的回复!这与我一直尝试调试的方式相比,无疑是一个进步。不幸的是,我仍然无法找出applescript的错误…它适用于我的常规文件夹,是在文件夹操作设置中设置的文件夹和操作…?是在文件夹操作设置中设置的。这很奇怪——对我来说,它会启动iTunes,但不会将文件添加到播放列表中。这可能与Dropbox文件夹中的文件夹有关吗?疯狂的是,它能正常工作:
code
set playtToUpdate为“公共新闻服务”,set items为“Macintosh HD:Users:Shared:Dropbox(Wave Farm):WGXC Studio Audio:Public News Service:Mamas 96 K Master 3.24 RUNAWAY MOON.mp3”作为别名告诉应用程序“iTunes”启动add items to add to playlist playtitoupdate end tell
code
,但在将其附加到文件夹时不启动……Dropbox应该像文件夹一样工作-如果将其附加到常规文件夹,它是否工作?
property playlistToUpdate : "Public News Service"

on run -- applet or from the Script Editor
    doStuff for (choose file with multiple selections allowed)
end run

on open droppedItems -- droplet
    doStuff for droppedItems
end open

on adding folder items to theFolder after receiving theNewItems -- folder action
    doStuff for theNewItems
end adding folder items to

to doStuff for someItems -- the main stuff
    set filesAdded to {}
    repeat with anItem in someItems
        tell application "iTunes"
            launch
            delay 2
            display dialog (anItem as text)
            add anItem to playlist playlistToUpdate
        end tell
    end repeat
end doStuff