Created
March 5, 2020 12:58
-
-
Save simonliu009/9f6a475c8068152907165c19f2e856f8 to your computer and use it in GitHub Desktop.
[shell脚本批量修改]#shell #scripts #脚本
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Function:rename files | |
#Created by xiaoyu | |
mname=0 #声明变量 | |
for file in `ls` #遍历当前目录下的所有文件 | |
do | |
fname=${file:0:1} #截取文件名的前1个字符 | |
bname=${file:0-8} #截取文件名的后8个字符 | |
let "mname = mname + 1" | |
filename=$fname$mname$bname #拼接最终文件名 | |
mv $file $filename #修改该文件的文件名 | |
done | |
———————————————— | |
版权声明:本文为CSDN博主「xiaoyu-Wang」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。 | |
原文链接:https://blog.csdn.net/u014656992/article/details/71023161 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment