Advertisement
savoxis

mp3sort

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