#!/bin/sh # take every file in the directory and place it in a sub-directory # with the correct 4-char siteid # if the subdirectory does not exist create it # if the file has the same name as an existing one then send an # error message for file in `ls ????*.jpg`;do site=`echo $file |cut -c1-4` if [ ! -s $site ];then mkdir $site fi if [ -s $site/$file ];then echo " The file $file has the same name as an existing file" echo " please rename file. It will be left in the current" echo " directory" else mv -i $file $site/. fi done