【发布时间】:2021-08-21 09:10:09
【问题描述】:
我正在创建一个处理新文件夹的文件夹操作 (Automator Mac)。我的代码是第一部分。它将删除的文件夹的名称修剪为 8 个字符。现在它需要将修剪后的文件夹名称附加到里面的所有文件,并将文件向上移动一个级别(文件夹被删除的位置)。最后,需要删除空文件夹。
Automator > 运行 Shell 脚本
- 外壳:
/bin/zsh - 传递输入:作为参数
for f in "$@"; do
autoload zmv // not sure where to put this
if [[ $f == *""* ]]; then // currently set to be unfiltered
filename=$f:t
filepath=$f:h
dest=$(echo $filename | cut -c1-8) // var of dropped folder name. first 8 chars
mv $filepath/{"$filename","$dest"} // trims dropped folder to 8 chars
zmv '(**/)(*).png' 't_$1$2.png' // this doesnt work here, BUT works in terminal. "t_" is temporary
fi
done
为什么 zmv 命令在 shell 脚本中不起作用?或者有更好的方法吗?
【问题讨论】:
-
为什么
--前面有zmv?为什么您的文件以-- /bin/zhs pass inputs as parameters开头?后者应该是#!/bin/zsh吗?还是这是某种复制粘贴错误? -
我不知道。我正在努力学习。
-
代码不是你自己写的?
-
我写了代码,马龙。我只是说我在学习。