mac linux 批量重命名脚本

有的时候为对照片视频进行重命名操作,文件少的时候手动也很快,但是当要重命名的文件数量很多的时候,单纯的靠手动来修改就不是那么容易了,烦的就是重复的操作,这边提供一个脚本来实现批量重命名,思想就是ls目录下面的文件,然后循环重命名,运行该脚本的时候中心文件的前缀和要重命名的文件夹路径就行过了。

重命名脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
#########################################
# batch rename                          #
# Input  :    $1 prex of new file name  #
#                  eg:cooking           #
# Input  :    $2 dir of the file        #
#                  eg:~/Desktop/photo   #
# author  :   www.fly3q.com             #
#########################################
if [ ! '$1' ];then
echo "add prex for new file name\n"
exit
fi
if [ ! '$2' ];then
echo "add dir of the file\n"
exit
fi

cd $2
len=1
for file in `ls`
do
if [ `echo $file|grep '.JPG'` ] || [ `echo $file|grep '.jpg'` ];
then
newFileName=`echo $1'_'$len'.jpg'`
elif [ `echo $file|grep '.PNG'` ] || [ `echo $file|grep '.png'` ];
then
newFileName=`echo $1'_'$len'.png'`
elif [ `echo $file|grep '.BMP'` ] || [ `echo $file|grep '.bmp'` ];
then
newFileName=`echo $1'_'$len'.bmp'`
elif [ `echo $file|grep '.rmvb'` ] || [ `echo $file|grep '.RMVB'` ];
then
newFileName=`echo $1'_'$len'.rmvb'`
else
newFileName=$file
fi

mv $file $newFileName
echo "mv $file $newFileName\n"
((len++))
done

点我下载

无觅相关文章插件,快速提升流量

Leave a comment

4 Comments.

  1. 关于linux的忘得差不多了,来学习下。


发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*


您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Bad Behavior has blocked 1448 access attempts in the last 7 days.

site tracking with Asynchronous Google Analytics plugin for Multisite by WordPress Expert at Web Design Jakarta.

serial corel draw 11

serial corel draw 11 serials

free corel photoshop download

free corel photoshop download keygen

adobe free

adobe free

key office 2010

office 2010 key

download photo shop free

photo shop serial

free winrar download for xp

download winrar for xp for free

windows 7 free

windows 7 crack

cs5 serialz

cs5 serialz free

free corel downloads

free corel downloads cracked

office 2010 free

office 2010 key

winrar password cracker serial

wirar password cracker

serial winzip 11

serial winzip 11 key

photoshop key

photoshop key

windows key

windows key

corel dvd moviefactory 6

corel dvd moviefactory 6 downloads

office 2010 professional key

office 2010 key

photo shop key

photo shop key

winrar 3 download

winrar 3 download freedownload

windows 7 key

windows 7 key