您当前的位置: 首页 >  linux

柳鲲鹏

暂无认证

  • 0浏览

    0关注

    4642博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

LINUX下,用脚本处理一个目录所有文件的代码

柳鲲鹏 发布时间:2018-09-15 15:41:55 ,浏览量:0

  文件convert-dir.sh


ROOT_DIR=/media/quantum6/disk/SOFTWARE/videos/wuxi
CONVERT_H264=/home/quantum6/Develop/videos/convert_to_h264_by_nv.sh

cd $ROOT_DIR

# 只列出目录
for path in $(ls -d *)
do
    # 检测是否目录 在次基础上进行递归处理。
    full_path=$ROOT_DIR/$path
    if [ -d $full_path ] ; then
        echo $full_path
    fi

    cp $CONVERT_H264 $full_path
    cd $full_path

    # 只列出文件
    for file in $(ls -f *)
    do
        # 检查是否文件
        # if [ -f $file ] ; then

        # 以converted-开头的不处理
        if [[ ${file:0:10} = "converted-" ]] ; then
            echo converted
            continue
        fi

        # 以h264结尾的不处理
        if [ "${file##*.}" = "h264" ]; then
            echo h264
            continue
        fi

        # 这个文件已经转换过了
        confile=converted-$file.h264
        if [ -f $confile ] ; then
            echo has converted $file
            continue;
        fi

        # 这些才处理。
        echo process $file
        ./convert_to_h264_by_nv.sh $file

    done
done

  同目录下有文件convert_to_h264_by_nv.sh。

  子目录是wuxi,执行:

convert-dir.sh wuxi

 

关注
打赏
1665724893
查看更多评论
立即登录/注册

微信扫码登录

0.0656s