分类
服务器日志

Lame压缩mp3文件

#!/bin/bash

#colors
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'

#total number of mp3
exts=(*.mp3)
count=${#exts[@]}

SAVEIFS=$IFS
IFS=$(echo -en "\n\b")

for file in $(ls *.mp3)
do
	printf "${GREEN} There are ${count} files to process!\n"
	name=${file%%.mp3}
	#to see if there is aready a compressed version
	compname=${name}_compressed.mp3
	if [ -f "$compname" ]
	then 
		printf "${GREEN}There is aready has a compressed version of ${RED}$name\n${NC}"
		rm "${name}.mp3"
		continue # we just delete the duplicated file
	fi
	if [[ "$name" == *"compressed"* ]]
	then
		printf "${RED}$name ${GREEN}is already compressed\n${NC}"
	else
		printf "${GREEN}Ready to compress ${RED}$name\n${NC}"
		lame -V9 -h --vbr-new ${name}.mp3 ${name}_compressed.mp3
		rm "$name.mp3"
	fi
	count=$[${count}-1]
done

IFS=$SAVEIFS

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据