Skip to content

Instantly share code, notes, and snippets.

@FernandoEscher
Created September 5, 2012 19:10
Show Gist options
  • Save FernandoEscher/3642776 to your computer and use it in GitHub Desktop.
Save FernandoEscher/3642776 to your computer and use it in GitHub Desktop.
Renaming the folders generated by abcde CD ripper
#!/bin/bash
SEPARATOR="-"
DIRS="${PWD}/*"
for dir in $DIRS
do
if [[ -d $dir && $dir == *-* ]]
then
dirname=$(basename $dir)
artist=${dirname%-*}
artist=${artist//_/ }
album=${dirname##*-}
album=${album//_/ }
echo "Found artist \"$artist\" with album \"$album\""
if [ ! -d "${PWD}/$artist" ]
then
echo "Creating directory \"$artist\""
mkdir "${PWD}/$artist"
fi
mv $dir "${PWD}/$artist/$album"
echo "Moved to $artist/$album/"
fi
done
echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment