sh wav2mp3

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh wav2mp3相关的知识,希望对你有一定的参考价值。

#!/bin/bash
process() {

	dir=$@
	echo "processing $dir/"
	
	FILES=$@/*
	IFS=$(echo -en "\n\b")
	for file in $FILES; do
		if [ -f "$file" ]; then
			# echo "found file $file"

			if [[ $file == *.wav ]]; then
				dir=$(dirname "$file")
				fileWithoutExt=$(basename "$file" .wav)
				mp3file="$dir/$fileWithoutExt.mp3"
		
				if [ -f "$mp3file" ]; then
					echo "$mp3file already exist"
				else
					echo "converting $file..."
					lame "$file"
				fi
			
				if [ force ]; then
					rm -f "$file"
					echo "removed $file"
				else
					rm -i "$file"
				fi
			fi	

		elif [ -d $file ]; then
			# echo "found directory $file"
			process $file

		fi
	done
}

while getopts "f" arg; do
  case $arg in
    f)
      force=true
      ;;
  esac
done

process $(pwd)

以上是关于sh wav2mp3的主要内容,如果未能解决你的问题,请参考以下文章

如何使我的命令行在具有扩展名(.sh)和名称如“weird.sh.sh.sh”的文件上工作

sh sh_template.sh

sh sh.sh

Linux下面如何运行 SH文件

配置告警系统主脚本main.sh mon.sh load.sh 502.sh disk.sh

shell 脚本各种执行方式(source ./*.sh, . ./*.sh, ./*.sh)的区别