2013-10-10 302 views
3

我试图在Wirecast中编写媒体文件的打开脚本。 我想打开Wirecast“镜头”的特定文件夹中的所有文件。AppleScript:获取POSIX路径到文件夹中的所有文件

按照词典的Wirecast的AppleScript的命令语法加一出手就是:

AddShotWithMedia 与posix_path 什么

我无法弄清楚如何要么得到的名单posix路径指向文件夹中的所有文件,或者将AppleScript路径转换为Wirecast可接受的posix路径。

下面的代码:

tell application "Finder" 
    set SettingsFolder to folder "WirecastMedia" of home 
    set MediaFolder to folder "Titles" of SettingsFolder 

    set TitleList to entire contents of MediaFolder 
end tell 

tell application "Wirecast" 
    activate 
    set myFile to (file "KorgWirecast.wcst" of SettingsFolder) 
    open myFile as alias 
    set myDoc to last document 
    set myLayer to the layer named "Titles" of myDoc 

    repeat with aFile in TitleList 
     AddShotWithMedia myLayer with posix_path aFile 
    end repeat 

end tell 

...它失败与消息的AddShotWithMedia行:

Can’t make «class docf» "ManyVoicesSuper.png" of «class cfol» "Titles" 
of «class cfol» "WirecastMedia" of «class cfol» "ram" of «class cfol» 
"Users" of «class sdsk» of application "Finder" into the expected type. 

回答

4

file "ManyVoicesSuper.png of folder "Titles" ... of application "Finder"是一个Finder参考文件。你需要的是一个POSIX路径形式的字符串。我注意到你正在使用的文件夹,其中包含子文件夹的entire contents,但如果你只需要获取文件从顶部的文件夹,你可以使用系统事件是这样的:

tell application "System Events" 
    set TitleList to POSIX path of disk items of folder "~/WirecastMedia/Titles" 
end tell 
+0

完美!谢谢!我花了我所有的时间试图强制从一种形式到另一种形式的路径。奇怪的是,你必须通过一个大脚本来执行两种不同的路径格式。你会认为会有一种强制路径格式的标准方式。 –

相关问题