用shell脚本批量修改当前目录下的文件名

发表于:2007-05-26来源:作者:点击数: 标签:
批量修改当前目录下的文件名

#!/bin/sh
for fname in *;do
tmp=`echo $fname|tr [a-z] [A-Z]`                   #note ,tr can't act like this: tr fname [a-z] [A-Z]'因为它只从标准输入读取数据
                   # it must run as this'tr <fname [a-z] [A-Z]',but this will upcased the content of fname
                   #so,if you want rename a file list,you must redirect tr's stdin to some command's stdout
mv $fname $tmp
done

#the above code cost me lots of time!^-^

原文转自:http://www.ltesting.net