想批量重命名mp3文件到以下方案my-artist_my-title.mp3
例如:假设我有mp3
文件:of the song Underground‐Čoček, by Goran Bregović。但文件名为s3 24)3ü6 Dț67 .mp3
(例如,因为它在驱动器和recovered with testdisk
上丢失。假设mp3元数据正确,脚本应将文件名更改为:goran-bregovic_underground‐cocek.mp3
个
理想情况下,我希望有一个bash script
,我会触发:
$ rename-mp3 directory-with-subdirectories-with-mp3-files
字符串
搜索类似的解决方案,我发现this函数。我修改了它,它的作品,* 部分 *!标记为#?
的正则表达式修改不起作用。
function rename-mp3() { # input is an mp3 file: i.e. find -name 's3 24)3ü6 Dț67 .mp3' -exec bash -c 'rename-mp3 "$@"' bash {} \;
# extract metadata from file
artist=`ffprobe -loglevel error -show_entries format_tags=artist -of default=noprint_wrappers=1:nokey=1 "$1"`
title=`ffprobe -loglevel error -show_entries format_tags=title -of default=noprint_wrappers=1:nokey=1 "$1"`
artist="${artist/\&/}" #? delete all non-numeral, non-latin, and non-space characters (&, %, !, ', ä, ö, ü, ă, ț, etc.)
title="${title/\&/}" #? delete all non-numeral, non-latin, and non-space characters (&, %, !, ', ä, ö, ü, ă, ț, etc.)
artist="${artist// +/\-}" #? replace all spaces with "-", if more then one in sequence substitute only one "-"
title="${artist// +/\-}" #? replace all spaces with "-", if more then one in sequence substitute only one "-"
filename="$artist_$title.mp3" # paste artist and title together
filename="${name,,}" # lowercase everything
echo "$filename" # display new filename
cp "$1" "renamed/$name" # copy renamed file to the renamed folder
}
型
1条答案
按热度按时间z9ju0rcb1#
我使用一个类似的脚本(但实际上更复杂)来排序我所有的音频文件。
根据你的剧本:
字符串