带有变量的终端命令的Automator Service

我是一位寻求自动化某些流程的艺术家。不幸的是,即使是这个看似基本的问题,我也无法编码。我在此任务上需要专业人士的帮助:

我需要通过Automator创建一个服务,该服务将使用FFMPEG重新编码视频文件。在终端中执行这样的行时,它基本上应该执行我正在做的事情:

ffmpeg —i FILE_NAME.EXTENSION -vf "vflip,hflip" -an FILE_NAME_converted.MP4

将此脚本包装到服务中后,必须用应用该服务的文件替换FILE_NAME。如何在Shell-script的AppleScript中使用此类变量?我将不胜感激任何建议,甚至分步说明。谢谢!

weiqingtao 回答:带有变量的终端命令的Automator Service

我能够弄清楚。这是适用于我的AppleScript代码:

on run {input,parameters}
    tell application "Finder"
        set theWin to window 1
        set thePath to (POSIX path of (target of theWin as alias))
        set theFile to name of file input
    end tell

    tell application "Terminal"
        activate
        set currentTab to do script ("cd " & thePath)
        do script ("ffmpeg -i " & theFile & " -vf \"vflip,hflip\" -an " & theFile & "_converted.mp4") in currentTab
        set frontWindow to window 1
        repeat until busy of frontWindow is false
            delay 1
        end repeat
        quit
    end tell
end run
本文链接:https://www.f2er.com/3107981.html

大家都在问