Your best friend for file transfer.

Fetch application logoFetch

Help with automation script (2 posts)

  • Started 13 years ago by Help with fetch and automation
  • Latest reply 13 years ago from Jim Matthews
  • Help with fetch and automation Member

    Hello, I am trying to make an automator workflow that takes a movie file, runs a little script to convert to ogv file, then uploads them to my server using Fetch. Below you can see the screenshot of what I have:
    <img src="http://emberapp.com/memincalcetin/images/convert-to-ogv-workflow-1/sizes/m.png" title="convert to ogv.workflow" />
    Right now what this does is it will convert the m4v file to ogv and ONLY upload the m4v file. I want the script to give the output of the conversion, the ogv file ALSO to the UPLOAD FILES command, not just the m4v file. Is there a small addition to the script i could do to make this happen?

    Posted 13 years ago #

  • Jim Matthews Administrator

    Hi,

    You need your script action to output both the file that was passed to it, and the ogv file you created. To do that you need to turn the name of the input file into the name of the created file (i.e. replace the m4v extension with ogv).

    I do not know how to do this in shell programming, but the following AppleScript should work in a Run AppleScript action:

    on POSIXPathOfFileWithNewExtension(inFile, inNewExtension)
    set oldExtension to name extension of (info for inFile)
    set oldExtensionLength to length of oldExtension
    set oldPath to POSIX path of inFile
    set oldPathLength to length of oldPath
    set newPath to ((characters 1 thru (oldPathLength - oldExtensionLength) of oldPath) as string) & inNewExtension
    return newPath
    end POSIXPathOfFileWithNewExtension

    on run {input, parameters}

    set outputItems to {}

    repeat with oneFile in input
    set outputItems to outputItems & {contents of oneFile}

    set filePath to POSIX path of oneFile
    do shell script "/usr/local/bin/ffmpeg2theora '" & filePath & "'"

    set newFilePath to POSIXPathOfFileWithNewExtension(oneFile, "ogv") of me
    set outputItems to outputItems & {POSIX file newFilePath}
    end repeat

    return outputItems
    end run

    Thanks,

    Jim Matthews
    Fetch Softworks

    Posted 13 years ago #

Reply

  • Or nickname, if you prefer.
  • This will be kept confidential.
  • This is to ensure that you’re a person, not a spambot.