Skip to content

Instantly share code, notes, and snippets.

@mydnic
Created November 4, 2016 14:32
Show Gist options
  • Save mydnic/36cf5dd1ae5551a9c3d306a308303dc5 to your computer and use it in GitHub Desktop.
Save mydnic/36cf5dd1ae5551a9c3d306a308303dc5 to your computer and use it in GitHub Desktop.
Shell script to move all mp3 files into directories having the name of the artist
find . -name "*.mp3" -type f -printf "%f\n" |
while read filename
do
music=${filename%.mp3}
artist=${filename% -*}
if [ -d "$artist" ]; then
mv "$filename" "$artist"
else
mkdir -pv "$artist"
mv "$filename" "$artist"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment