通过使用shell脚本替换文件名中的特定模式来重命名多个文件
发布时间:2020-12-15 16:29:26 所属栏目:安全 来源:网络整理
导读: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 camer
我需要为此写一个shell脚本。有人可以建议如何开始?
一个帮助你离开地面的例子。
for f in *.jpg; do mv "$f" "`echo $f | sed s/IMG/VACATION/`"; done 在这个例子中,我假设你的所有图像文件以“IMG”开头,并且你想用“VACATION”替换“IMG”。 shell自动对所有匹配的文件评估* .jpg。 mv(文件的新名称)的第二个参数是sed命令的输出,它将“IMG”替换为“VACATION”。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |