将 shell 结果传递给另一个 shell 命令?
刚刚在这里学习 Automator,但我正在尝试对文件(blah.rtf->blah.mobi)运行转换命令,并且我想获取生成的 .mobi 文件并在其中运行另一个 shell 命令不同的动作。或者有没有办法将其设置为第二个变量并在同一操作中对其进行操作?
这是到目前为止我的代码(使用 Calibre 命令行工具):
第一个操作:
for f in "$@"
do
ebook-convert "$f" "$f".mobi
done
我想传递 .mobi 文件来运行:
for f in "$@"
do
mv "$f" $(echo "$f" | cut -d'.' -f1).mobi
done
有什么想法吗?谢谢!
Just learning Automator here, but I'm trying to run a convert command on a file (blah.rtf->blah.mobi) and I'd like to take the resulting .mobi file and run another shell command on it in a different action. Either that, or is there a way to set it as a second variable and act on it in the same action?
Here's my code so far (using Calibre command-line tools):
First action:
for f in "$@"
do
ebook-convert "$f" "$f".mobi
done
I'd like to pass that .mobi file to run:
for f in "$@"
do
mv "$f" $(echo "$f" | cut -d'.' -f1).mobi
done
Any thoughts? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了将转换后的文件传递给后续操作,第一个操作必须输出它们的路径:
但是您可以通过让第一个操作首先创建具有正确名称的文件(如@tripleee建议的那样)来使其变得更简单:
In order to pass the converted files to subsequent actions, the first action must output their paths:
But you can make it much simpler by making the first action create the files with the correct names in the first place (as @tripleee suggested):