美文网首页
Shell文件中查找图片文件

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文件中查找图片文件

  • Python3 提升你脚本的逼格系列(二)

    通过文件名查找文件 有时候,你不想在 Python 脚本中调用 shell,或者你要实现一些 shell 不能做的...

  • 2019-12-29 shell命令行操作

    shell命令行操作 1.判断文件夹存在,不存在则创建,判断文件是否可以执行 查找whl文件并且复制 查找run文...

  • MAC Shell 命令 find 简单应用

    MAC Shell 命令 find 简单应用 find命令行的例子: 查找目录 查找文件 递归删除指定名字的文件或...

  • 03_shell面试题

    问题1[金和网络]:请用shell脚本写出查找当前文件夹(/home)下所有的文本文件内容中包含有字符”shen”...

  • 终端用shell读写plist文件

    【原帖置顶】shell文件中读取plist文件并实现shell中的数值计算 Mac操作plist文件用PlistB...

  • linux命令记录

    查找文件 find / -name fileName 在根目录中查找文件fileName 在文件中检索字符 ...

  • 在项目中查看某一类文件脚本

    场景 想查找下项目中哪一类文件中,哪个文件比较大,进行优化想查找下主项目中有哪些图片,哪些比较大查找下项目中是否有...

  • vi 命令收集

    /word 这个是查找文件中“word”这个单词,是从文件上面到下面查找?word 这个是查找文件中“word...

  • Linux中常用的查找命令

    linux 中常用的查找文件和文件中字符串的操作: 在某个路径下查找文件 例如在 /etc 中查找 "*.log"...

网友评论

      本文标题:Shell文件中查找图片文件

      本文链接:https://www.haomeiwen.com/subject/wbahdxtx.html