Advertisement
metalx1000

MP3 - Sorter - Orginizer

Feb 22nd, 2014
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.78 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. mkdir misc
  4.  
  5. for i in *.mp3
  6. do
  7.     echo "$i"
  8.  
  9.     #move all file without tags to "misc" folder
  10.     x="$(id3tool "$i"|head -n2|tail -n1)";
  11.     if [ "$x" = "No ID3 Tag" ];
  12.     then
  13.         mv "$i" misc
  14.     fi
  15.  
  16.     #get tag info, create folders, move mp3
  17.     TITLE="`id3tool "$i" | grep '^Song Title:' | awk '{ for (i=3;i<=NF;i++) { printf $i } }'`"
  18.     ARTIST="`id3tool "$i" | grep '^Artist:' | awk '{ for (i=2;i<=NF;i++) { printf $i } }'`"
  19.     ALBUM="`id3tool "$i" | grep '^Album:' | awk '{ for (i=2;i<=NF;i++) { printf $i } }'`"
  20.     YEAR="`id3tool "$i" | grep '^Year:' | awk '{ for (i=2;i<=NF;i++) { printf $i } }'`"
  21.     TRACKNUM="`id3tool "$i" | grep '^Year:' | awk '{ print $2 }'`"
  22.    
  23.     dir="$ARTIST/$ALBUM/"
  24.  
  25.     mkdir -p "$dir"
  26.     mv "$i" "$dir"
  27. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement