从$ filename_h目录下的所有文件重命名为$ filename_half? [英] Rename all files in directory from $filename_h to $filename_half?

查看:97
本文介绍了从$ filename_h目录下的所有文件重命名为$ filename_half?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

死的简单。

如何重命名

05_h.png
06_h.png

05_half.png
06_half.png

至少,我认为这很简单,但它很难对谷歌这种事情,除非你已经知道了。

At least, I think it's simple, but it's hard to Google for this kind of thing unless you already know.

感谢....

推荐答案

只需使用bash,不需要调用外部命令。

Just use bash, no need to call external commands.

for file in *.png
do
  mv "$file" "${file/_h.png/_half.png}"
done

不要添加#!/ bin / sh的

Do not add #!/bin/sh

对于那些需要一个单行:

For those that need that one-liner:

for file in *.png; do mv "$file" "${file/_h.png/_half.png}"; done

这篇关于从$ filename_h目录下的所有文件重命名为$ filename_half?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆