shell查找移动指定类型的文件
#!/bin/bash
function ergodic(){
for file in `ls $1`
do
if [ -d $1"/"$file ]
then
ergodic $1"/"$file
else
local path=$1"/"$file
local name=$file
category=${name##*.}
res="flac"
if [[ "$category" == "flac" ]];then
echo "$category"
`cp "$path" "/Users/xxx/Documents/歌曲/周杰伦/AllFlac"`
fi
fi
done
}
IFS=$'\n' #这个必须要,否则会在文件名中有空格时出错
INIT_PATH="/Users/xxx/Documents/歌曲/周杰伦";
ergodic $INIT_PATH