批量文件改名
2014-11-12有一批csv文件,想改为数字为文件名001.csv--999.csv
例如:
#!/bin/sh
ls -l
max=`find . -type f -name '*csv'|wc|awk '{print $1}'`
x=(`seq -f %03g 1 ${max}`)
i=0
for file in `find . -type f -name '*.csv'`;do
mv $file ${x[$i]}.csv
((i=i+1))
done
ls -l
或者
#!/bin/sh
i=1
for file in `find . -type f -name "*.flv"`;do
if (( i<=9 ));then
mv $file 0${i}.flv
else
mv $file ${i}.flv
fi
((i=${i}+1))
done