shell编程之批量修改文件名字
1.准备数据源:
mkdir sub_str
cd sub_str/
touch chaoge_{1..5}_finished_jpg
touch chaoge_{1..5}_finished_png
2.利用变量的子串功能,修改字符串信息
mv chaoge_1_finished_jpg chaoge_1_jpg
f=chaoge_1_finished_png
echo $f
echo ${f//_finished/}
3.利用反引号的取结果功能
echo `date`
4.批量文件名替换,只修改jpg
for file_name in `ls *fin*jpg`; do mv $file_name `echo ${file_name//_finished/}`; done
date:20220812
author:liudiyang