File copier script

Hi

I am trying to write a shell script that will check a directory for a file/files. If any are present it will copy the file to a different directory and append a unique number to theend of the file name.

Has anybody done anything like this? I would really appreciate any advice on how to do this.

Hi Paul ... Excerpts from one of the similar scripts i created for backing up old SQL file . U can modify it accordingly

echo "           BACKING UP PREVIOUS SQL FILE ...."
echo "           ---------------------------------"
if    [ -f old_file_name ]
  then 
        mv old_file_name.sql  moved_old_file_name.sql  
fi
        sleep 2

Hope this will give u a basic idea of how to proceed .. We are always to help in case u get stuck up anywhere :slight_smile:

assuming you have no subtree ...

find sourcedir -type f | while read a ; do ; let i++ ; cp "$a" targetdir/"${a##*/}.$i"; done

Thanks for your replies.

One more thing. I just found out that I will need to copy my updated file name to a folder on a windows server. Am I correct in thinking I will need to FTP it?