Hi,
Do you want to manipulate the id3 tags embedded in the mp3 files (as opposed to manipulating the file names themselves)?
assuming that is the case, you could do something like this:
Code:
find Music -name '*.mp3' -exec ./capitalise_meta.sh noexec {} \;
where capitalise_meta.sh is this script:
the noexec option will display any tags that it would update but won't actually apply those updates. If the output looks reasonable then remove the noexec option to actually make the changes
i've no doubt there are cases this won't match particularly well, e.g. "this song's crap" would get capitalised to "This Song'S Crap". And depending on your music collection there'll probably be other corner cases also. Either fix those manually after running the script, or else refine the sed regex to do something more sophisticated.
Code:
#!/bin/bash
if [[ $1 == "noexec" ]]; then
noexec="1"
shift
fi
file=$1
[[ ! -f "$file" ]] && { echo "file not found: $file, exiting..."; exit 1;}
meta=$(id3tool "$file")
title=$(echo "$meta" | grep "Song Title:" | cut -d: -f2 | sed 's/^\s*//')
if [[ -n "$title" ]]; then
capitalised_title=$(echo "$title" | sed 's/\(\w\+\)/\u\1/g')
if [[ "$capitalised_title" != "$title" ]]; then
if [[ -z "$noexec" ]]; then
id3tool -t "$capitalised_title" "$file"
else
echo "Noexec: Title: $title => $capitalised_title"
fi
fi
fi
artist=$(echo "$meta" | grep "Artist:" | cut -d: -f2 | sed 's/^\s*//')
if [[ -n "$artist" ]]; then
capitalised_artist=$(echo "$artist" | sed 's/\(\w\+\)/\u\1/g')
if [[ "$capitalised_artist" != "$artist" ]]; then
if [[ -z "$noexec" ]]; then
id3tool -r "$capitalised_artist" "$file"
else
echo "Noexec: Artist: $artist => $capitalised_artist"
fi
fi
fi
good luck
Bookmarks