最大3分の長さのビデオファイル(* .mp4)を移動して名前を変更する

最大3分の長さのビデオファイル(* .mp4)を移動して名前を変更する

3分未満のすべてのビデオファイルを移動/名前変更(および/またはシンボリックリンクを生成)するbashスクリプトを作成しようとしています。

これまで、私は次の find コマンドを持っています。

find "$findpath" -maxdepth "2" -type f -name '*.mp4' -print -exec avprobe -v error -show_format_entry duration {} \;

それから

if [ $duration -ge $DUR_MIN -a $dur -le $DUR_MAX ]
cd "$path2"
ln -sFfhv "$path1$file" "$file2"
fi

ベストアンサー1

これはあなたが望むものですか?

dur_min=180
dur_max=3600 # or whatever you want the max to be

# find the appropriate files and deal with them one at a time
find "$findpath" -maxdepth 2 -type f -iname '*.mp4' -print |
    while read file ; do
        # read duration
        duration="$(ffprobe -v quiet -print_format compact=print_section=0:nokey=1:escape=csv -show_entries format=duration "$file")"
        # trim off the decimals; bash doesn't do floats
        duration=${duration%.*}
        if [[ $duration -gt $dur_min ]] && [[ $duration -lt $dur_max ]] ; then
            echo "$file is $duration seconds long (rounded down)"
            # do whatever you want, mv, ln, etc.
        fi
    done

iname注大文字と小文字を区別せずにname(* .MP4など)使用してください。

また、私はavprobe(私は持っていません)の代わりにffprobeを使用していますが、ffmpegタグがあるので大丈夫でしょうか?

おすすめ記事