#脚本功能:查找某个文件夹,将符合条件文件夹的指定文件名拷贝成其他的文件名
#shell点:遍历文件夹,判断指定文件路径,查找文件,文件名替换
#!/bin/sh
func(){
curdir=$1
local path=$curdir
for file in `ls $curdir`
do
if [ -d "$path/$file" ];then
func "$path/$file"
elif [ -f "$path/$file" ];then
#if [ -n "`echo $path|grep 142`" ]#只检查一个字符
if [ -n "`echo $path|grep -E "(141|142)$"`" ]#可以检查多个字符
then
if [ -n "`echo $file|grep _100_100`" ]
then
old=$file
new=${old/_100_100/_180_140}
new2=${old/_100_100/_240_240}
cp "$path/$old" "$path/$new"
cp "$path/$old" "$path/$new2"
echo "$new"
echo "$new2"
echo "$path/$new"
echo "$path/$new2"
fi
echo "$path/$file"
fi
fi
done
}
func "/r/img/2011"
转载于:https://blog.51cto.com/seared2008/736554