首页 > 解决方案 > Bash试图将转换后文件的名称写入文本

问题描述

我有这个脚本,我用它把我的文件转换为 16 位。我想知道哪些文件已被转换,因此我尝试将它们写入列表。但是,即使文件已被转换,创建的文件仍为空。怎么了?

#!/bin/bash
files=()
find . -name "*.wav" -o -name "*.WAV"|while read i; do
  if [ "$(ffprobe -v error -show_entries stream=sample_fmt -of csv=p=0 "$i")" != "s16" ] || [ "$(ffprobe -v error -show_entries stream=sample_rate -of csv=p=0 "$i")" != "44100" ]
    then
      ffmpeg -y -i "$i" -c:a pcm_s16le -ar 44100 "${i%.*}_16.wav";
      files+=("$i");
  fi
done

printf "%s\n" "${files[*]}" > converted_files.txt;

标签: bashshellwindows-subsystem-for-linux

解决方案


推荐阅读