【发布时间】:2018-02-17 08:24:19
【问题描述】:
环顾四周,我没有看到我在寻找什么。一些类似的东西,但由于某种原因,我到目前为止尝试的方法没有奏效。
我的主要目标:
- 在我的当前目录中运行脚本
- 打开图片看看是什么
- 重命名刚刚查看的图片
- 重复该过程而不再次运行脚本
这些是我试图追踪的来源:
Bash Shell Loop Over Set of Files
Bash loop through directory and rename every file
How to do something to every file in a directory using bash?
================================================ ====================================
echo "Rename pictures. Path"
read path
for f in $path
do
eog $path
echo "new name"
read newname
mv $path $newname
cat $f
done
【问题讨论】:
-
您是否尝试在
eog行之后添加&&?eog $path && -
@JustinM.Keyes,这有什么好处?如果您想避免为
eog失败的文件运行其余的循环迭代,那么eog "$path" || continue会做得更好(不仅跳过echo,还跳过read、@987654332 @ 和cat)。