通过使用shell脚本替换文件名中的特定模式来重命名多个文件

Write a simple script that will automatically rename a number of files. As an example we want the file *001.jpg renamed to user defined string + 001.jpg (ex: MyVacation20110725_001.jpg) The usage for this script is to get the digital camera photos to have file names that make some sense.

我需要为此写一个shell脚本。有人可以建议如何开始?

一个帮助你离开地面的例子。
for f in *.jpg; do mv "$f" "`echo $f | sed s/IMG/VACATION/`"; done

在这个例子中,我假设你的所有图像文件以“IMG”开头,并且你想用“VACATION”替换“IMG”。

shell自动对所有匹配的文件评估* .jpg。

mv(文件的新名称)的第二个参数是sed命令的输出,它将“IMG”替换为“VACATION”。

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...