3

I'm trying to script the opening of media files in Wirecast. I want to open all of the files in a specific folder as Wirecast "shots".

According to the Wirecast Dictionary, the applescript command syntax to add a shot is:

AddShotWithMedia layer with posix_path anything

I can't figure out how to either get a list of posix paths to all the files in a folder, or alternatively, convert an applescript path to a posix path acceptable to Wirecast.

Here's the code:

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

...it fails on the AddShotWithMedia line with the message:

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.

1 Answer 1

4

file "ManyVoicesSuper.png of folder "Titles" ... of application "Finder" is a Finder reference to the file. What you need is a string in the form of a POSIX path. I notice you're using entire contents of the folder, which includes subfolders, but if you only need to get files out of the top folder, you can use System Events like this:

tell application "System Events"
    set TitleList to POSIX path of disk items of folder "~/WirecastMedia/Titles"
end tell
1
  • Perfect! Thank you! I spent all my time trying to coerce the path from one form to the other. Odd though that you have to carry two different path format through a large script. You would think there would be a standard way to coerce path formats. Oct 10, 2013 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.