本文介绍了HandBrakeCLI命令break while循环?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在bash脚本中,find的结果是

In a bash script, result of find is

/path/to/file1.nrg
/path/to/file2.nrg
/path/to/file3.nrg

while循环:

processpreset ()
{
    x=$1
    # Replace , by -o -iname for file types.
    iname=" -o -iname \*."
    # Find specified files. Eval allow var prst1_in with find.
    eval "find "$fpath" -type f \( -iname \*."${prst_in[x]//,/$iname}" \) -size ${prst_lim_size[x]}" | sort | while read -r i
    do
        titles=$(HandBrakeCLI --input "$i" --scan |& grep -Po '(?<=DVD has )([0-9]+)')
        if (( $titles > 1 )); then
        echo "DVD has $titles title(s)"
        fi
    done
}

脚本只回显1次文件在停止后有8个标题,当使用 titles = 8文件夹中所有文件的循环回显。谁能给我指出我的错误?

the script only echo 1 time File has 8 title(s) after it stop, when using titles="8" the loop echo for all files in folder. Can anyone point me my error please?

编辑:对我有用,非常感谢Anubhava

what work for me, many thanks Anubhava

processpreset ()
{
    x=$1
    # Replace , by -o -iname for file types.
    iname=" -o -iname \*."
    # Find specified files. Eval allow var prst1_in with find.
    eval "find "$fpath" -type f \( -iname \*."${prst_in[x]//,/$iname}" \) -size ${prst_lim_size[x]}" | sort | while read -r i
    do

    titles="$(echo ""|HandBrakeCLI --input "$i" --scan |& grep -Po '(?<=DVD has )([0-9]+)')"
    if (( $titles > 1 )); then
      echo "DVD has $titles title(s)"
    fi
    done
}

echo| 修复问题。

推荐答案

ok尝试此脚本:

while read -r i
do
        echo "i is: $i"
        titles="$(echo ""|HandBrakeCLI --input "$i" --scan | grep -Po '(?<=DVD has )([0-9]+)')"
        if (( titles > 1 )); then
           echo "DVD has $titles title(s)"
        fi
done < <(find "$imgpath" -type f \( -iname \*.iso -o -iname \*.nrg -o -iname \*.img \) | sort)

这篇关于HandBrakeCLI命令break while循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 06:24