Advertisement
savoxis

Untitled

May 26th, 2011
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.85 KB | None | 0 0
  1. #!/bin/bash
  2. #USAGE:
  3. #
  4. # basename $directory
  5. #
  6. # where $directory is the directory full of mp3s to sort (does not recurse)
  7. # and basename is w/e the hell you named the file
  8.  
  9. sortdir="/music"
  10.  
  11. for M in $1/*.mp3
  12.  do
  13.   TITLE="`id3tool "$M" | grep '^Song Title:' | awk '{ for (i=3;i<=NF;i++) { printf $i; printf " " } }'`"
  14.   ARTIST="`id3tool "$M" | grep '^Artist:' | awk '{ for (i=2;i<=NF;i++) { printf $i; printf " " } }'`"
  15.   ALBUM="`id3tool "$M" | grep '^Album:' | awk '{ for (i=2;i<=NF;i++) { printf $i; printf " " } }'`"
  16.   YEAR="`id3tool "$M" | grep '^Year:' | awk '{ for (i=2;i<=NF;i++) { printf $i; printf " " } }'`"
  17.   TRACKNUM="`id3tool "$M" | grep '^Year:' | awk '{ print $2 }'`"
  18.  
  19.   if [ ! -d "$sortdir" ];then
  20.    mkdir -p $sortdir/$ARTIST
  21.   fi
  22.  
  23.   echo "Sorting $M to $sortdir/$ARTIST"
  24.   install -D "$M" /music/"$ARTIST"/"$ARTIST-$TITLE".mp3
  25. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement