【发布时间】:2010-06-03 05:46:42
【问题描述】:
我找到了一个有用的 shell 脚本,它递归地显示目录中的所有文件。
在哪里打印文件名echo "$i"; #Display File name。
我想对非 MP3 文件运行 ffmpeg 命令,我该怎么做?我对 shell 脚本的了解非常有限,所以如果我被勺子喂食,我会很感激! :)
//if file is NOT MP3
ffmpeg -i [the_file] -sameq [same_file_name_with_mp3_extension]
//delete old file
这里是shell脚本供参考。
DIR="."
function list_files()
{
if !(test -d "$1")
then echo $1; return;
fi
cd "$1"
echo; echo `pwd`:; #Display Directory name
for i in *
do
if test -d "$i" #if dictionary
then
list_files "$i" #recursively list files
cd ..
else
echo "$i"; #Display File name
fi
done
}
if [ $# -eq 0 ]
then list_files .
exit 0
fi
for i in $*
do
DIR="$1"
list_files "$DIR"
shift 1 #To read next directory/file name
done
【问题讨论】: