shell - 带有变量的终端命令的自动化服务
问题描述
我是一名寻求自动化某些流程的艺术家。不幸的是,即使是这个看似基本的问题,我也离编码太远了。我在为这项任务寻求专业人士的帮助而哭泣:
我需要通过 Automator 创建一个服务,该服务将使用 FFMPEG 重新编码视频文件。它基本上应该做我在终端中执行时手动执行的操作,如下所示:
ffmpeg —i FILE_NAME.EXTENSION -vf "vflip,hflip" -an FILE_NAME_converted.MP4
当此脚本被包装到服务中时,FILE_NAME 必须替换为应用服务的文件。如何在 Shell-script 的 AppleScript 中使用这些变量?我将非常感谢任何建议甚至分步指导。谢谢!
解决方案
我能够弄清楚。这是适用于我的 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
推荐阅读
- tensorflow - 序列数据上的 LSTM,预测离散列
- django - 为普通用户复制 django admin
- matlab - Matlab中神经网络训练中的切换类
- symfony - 奏鸣曲管理员列表可编辑与编辑/显示冲突
- python - 在 Django 中根据请求自动添加新的 model_field || DRF
- android - 插入数据后,房间数据库表仍然为空
- microsoft-graph-api - 应用 $filter 选项在 Graph API 中检索具有特定名称的文件夹
- android - Android 找不到微调器的符号变量错误
- kubernetes - Kubernetes 节点详细信息
- python - 如何在跨平台的控制台中显示等宽字体(或恒定距离)?