View Single Post
Old 05-16-2008, 09:51 AM  
GrouchyAdmin
Now choke yourself!
 
GrouchyAdmin's Avatar
 
Industry Role:
Join Date: Apr 2006
Posts: 12,085
Oh, incidentally, this should actually do what you want without being quite so obnoxious. I don't trust having a 'smart' shell; just basic utilities that have been in UNIX since the 70s.

Code:
#!/bin/sh
PATH=/bin:/usr/bin:/sbin:/usr/sbin
FROMDIR=SET_BASEDIR_FOR_MOVE_FROM_HERE
TODIR=SET_DIR_TO_COPY_IT_TO_HERE
FILETYPE=jpg
APPENDSTART=1
for n in `find $FROMDIR -name \*.$FILETYPE -print`; do
   FILE=`basename "$n"`
   if [ -f "$TODIR/$FILE" ]; then
     while [ $APPENDSTART -le 100 ]; do
       APPENDSTART=`expr $APPENDSTART + 1`
       if [ ! -f "$TODIR/$APPENDSTART$FILE" ]; then
         FILE="$APPENDSTART$FILE"
         break;
       fi
     done
   fi
   echo "Moving '$n' to '$TODIR/$FILE'."
   mv "$n" "$TODIR/$FILE"
done
__________________
GrouchyAdmin is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote