SHARE
TWEET

mp3 loader for sansa on Linux 2

a guest Feb 1st, 2011 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. # grabs mp3's from last year and copies them to recentmp3 folder in home directory
  4.  
  5. # default to one year
  6. days=365
  7. if [ -n "$1" ]; then
  8.   days=$1
  9. fi
  10.  
  11. # change file separator so spaces work
  12. SAVEIFS=$IFS
  13. IFS=$(echo -en "\n\b")
  14.  
  15. # make directory if needed
  16. cd $HOME
  17. mkdir recentmp3
  18.  
  19. # go to mp3s
  20. cd /media/minion/multimedia/audio/legalmp3/amazon
  21. for f in *
  22. do
  23.   cd $f
  24.   for s in *
  25.   do
  26.     cd $s
  27.     for m in *.mp3
  28.     do
  29.       # copy mp3's one year old or less
  30.       find $m -mtime -$days -exec echo caching file {} \;
  31.       find $m -mtime -$days -exec cp $m $HOME/recentmp3/{} \;
  32.     done
  33.     cd ..
  34.   done
  35.   cd ..
  36. done
  37.  
  38. # copy mp3s to player
  39. cd $HOME/recentmp3
  40. for f in *.mp3
  41. do
  42.   newf=`echo $f | sed s/*//g` # sansa doesn't like asterices in filenames
  43.   echo copying cached file $f to player
  44.   cp $f /media/SANSA\ CLIPP/MUSIC/$newf
  45. done
  46.  
  47. # clean up mp3's
  48. cd $HOME
  49. rm -rf recentmp3
  50.  
  51. # return to orig file separators
  52. IFS=$SAVEIFS
  53.  
  54. echo DONE
RAW Paste Data
Top