This is the working code for an AppleScript Automator service to encode (ffmpeg) a user selected file to a user selected directory, keeping the the original file name with a new extension.:

on run {input, parameters}

    --choose destination folder
    set path1 to (choose folder)
    set path2 to quoted form of POSIX path of path1

    --reduce extension from source file name and set to unix path
    tell (info for input) to set {Nm, Ex} to {name, name extension}
    set filename to text 1 thru ((get offset of "." & Ex in Nm) - 1) of Nm
    set in_file to POSIX path of input

    --make new folder with source file name
    tell application "Finder"
        make new folder at path1 with properties {name:filename}
    end tell

    --run ffmpeg shell script (put whatever command you need here)
    tell application "Terminal"
        do script "ffmpeg -y -i " & in_file & " -c:v copy -c:a copy " & path2 & "/" & filename & "/" & filename & "_copy.mp4"
    end tell
end run

I hope this will help people struggling with AppleScript and asking themselves why-oh-why Apple prevents shell scripts from showing their progress.

tell application "Finder" to if name extension of item 1 of (get selection) is "mov" then set name extension of item 1 of (get selection) to "mp4"
  • Thanks. Can you elaborate on how to implement this in my (newly edited) original code? – o_ren Jul 8 '15 at 12:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .