View Single Post
jedi's Avatar
Posts: 1,411 | Thanked: 1,330 times | Joined on Jan 2010 @ Tatooine
#3
This was my version:
Code:
#!/bin/sh
MUSICDIR="/home/user/MyDocs/Music"
find "${MUSICDIR}" -iname *.jpg -o -iname *.jpeg | while IFS="" read FILE; do 
   DIRNAME=`dirname "${FILE}"`
   LASTPART=`echo "${DIRNAME}" | awk -F '/' '{print $NF}'`
   if [ "${LASTPART}" != ".mediaartlocal" ]; then
      if [ "$1" = "-d" ]; then  
         echo "${FILE} will be moved to ./mediaartlocal/"
      else
         echo "Moving ${FILE} -> ./mediaartlocal/"
         if [ ! -d "${DIRNAME}/.mediaartlocal/" ]; then
            mkdir "${DIRNAME}/.mediaartlocal/" 
         fi 
         mv "${FILE}" "${DIRNAME}/.mediaartlocal/"
      fi
   fi
done
Which does pretty much the same. You can run it with a '-d' option to simulate a dry-run (ie it won't change/move anything)
__________________
May the source be with you.
 

The Following 3 Users Say Thank You to jedi For This Useful Post: