Shell文件中查找图片文件
作者:
小弱鸡 | 来源:发表于
2017-08-21 22:41 被阅读62次#!/bin/sh
#
#脚本用于文件夹中图片资源的查找相应的资源
function getdir(){
# echo $1
for file in $1/*
do
if test -f $file
then
suffix=.png
if [[ $file == *$suffix ]]; then
# echo "222"
cp $file $storeDir
fi
arr=(${arr[*]} $file)
else
getdir $file
fi
done
}
# 获取当前文件夹
this_dir=`pwd`
# echo "$this_dir ,当前文件夹"
dirname $0|grep "^/" >/dev/null
if [ $? -eq 0 ];then
this_dir=`dirname $0`
else
dirname $0|grep "^\." >/dev/null
retval=$?
if [ $retval -eq 0 ];then
this_dir=`dirname $0|sed "s#^.#$this_dir#"`
else
this_dir=`dirname $0|sed "s#^#$this_dir/#"`
fi
fi
echo $this_dir
echo "请输入存储图片的文件夹名称按Enter结束:"
read storeDir
cd ..
if [ ! -d $storeDir ]; then
mkdir $storeDir
fi
getdir $this_dir
```
本文标题:Shell文件中查找图片文件
本文链接:https://www.haomeiwen.com/subject/wbahdxtx.html
网友评论