title: How to find,copy and rename files in linux?
body: <p>I am trying to find all files in a directory and sub-directories and then copy them to a different directory. However some of them have the same name, so I need to copy the files over and then if there are two files have the same name, rename one of those files.</p>
  
  <p>So far I have managed to copy all found files with a unique name over using:</p>
  
  <pre><code>#!/bin/bash
  if [ ! -e $2 ] ; then
      mkdir $2
      echo "Directory created"
  fi
  if [ ! -e $1 ] ; then
      echo "image source does not exists"
  fi
  find $1 -name IMG_****.JPG -exec cp {} $2 \;
  </code></pre>
  
  <p>However, I now need some sort of if statement to figure out if a file has the same name as another file that has been copied.</p>