Skip to content

Instantly share code, notes, and snippets.

@ChaunceyHoover
Last active March 3, 2020 06:04
Show Gist options
  • Save ChaunceyHoover/e4ba25ec15edce76793587056ada8cf8 to your computer and use it in GitHub Desktop.
Save ChaunceyHoover/e4ba25ec15edce76793587056ada8cf8 to your computer and use it in GitHub Desktop.
Run in Music folder - Removes artist name from album folder. NOTE: Comment out "mv" to make sure nothing unexpected happens
# Fixes error generated from using `mv` with files that have spaces in names
IFS='
'
for d in ./*/
do
cd "$d"
for f in ./*/
do
cd "$f"
for file in ./*
do
infile=`echo "${file:2}"|sed \
-e 's|"\"|"\\"|g' \
-e 's| |\ |g' -e 's|!|\!|g' \
-e 's|@|\@|g' -e 's|*|\*|g' \
-e 's|&|\&|g' -e 's|]|\]|g' \
-e 's|}|\}|g' -e 's|"|\"|g' \
-e 's|,|\,|g' -e 's|?|\?|g' \
-e 's|=|\=|g' `
outfileNOSPECIALS=`echo "${file:2}"|sed -e 's|[^A-Za-z0-9.\ \(\)\-]||g'`
outfileNOoe=`echo $outfileNOSPECIALS| sed -e 's|ö|oe|g'`
outfileNOae=`echo $outfileNOoe| sed -e 's|ä|ae|g'`
outfileNOue=`echo $outfileNOae| sed -e 's|ü|ue|g'`
outfileNOOE=`echo $outfileNOue| sed -e 's|Ö|OE|g'`
outfileNOAE=`echo $outfileNOOE| sed -e 's|Ä|AE|g'`
outfileNOUE=`echo $outfileNOAE| sed -e 's|Ü|UE|g'`
outfileNOss=`echo $outfileNOUE| sed -e 's|ß|ss|g'`
outfileNOtag1=`echo $outfileNOss| sed -e 's|\ MP3 320||g'`
outfileNOtag2=`echo $outfileNOtag1| sed -e 's|\ MP3 192||g'`
outfileNOtag3=`echo $outfileNOtag2| sed -e 's|\ MP3 256||g'`
outfileNOtag4=`echo $outfileNOtag3| sed -e 's|\ MP3 V2||g'`
outfileNOtag5=`echo $outfileNOtag4| sed -e 's|\ MP3 V1||g'`
outfileNOtag6=`echo $outfileNOtag5| sed -e 's|\ MP3 V0||g'`
outfileNOtag7=`echo $outfileNOtag6| sed -e 's|\ MP3 V4||g'`
outfileNOtag8=`echo $outfileNOtag7| sed -e 's|\ MP3 160||g'`
outfileNOtag9=`echo $outfileNOtag8| sed -e 's|\ MP3 128||g'`
outfile=${outfileNOtag9}
if [ "$infile" != "${outfile}" ]
then
echo "Renamed '"$infile"' to" $outfile
mv "$infile" ${outfile}
fi
done
cd ..
done
cd ~/Music
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment