title: bash scripting..copying files without overwriting
body: <p>I would like to know if it is possible to copy/move files to a destination based on the origin name.</p>
  
  <p>Basically, I have a /mail folder, which has several subfolders such as cur and new etc. I then have an extracted backup in /mail/home/username that is a duplicate. mv -f will not work, as I do not have permission to overwrite the directories, but only the files within.</p>
  
  <p>I get errors such as mv: cannot overwrite directory `/home/username/mail/username.com'</p>
  
  <p>What I want to do is for each file in the directory username.com, move it to the folder of the same name in /mail. There could be any number of folders in place of username.com, with seperate sub sirectories of their own.</p>
  
  <p>What is the best way to do this?</p>
  
  <p>I have to do it this way as due to circumstances I only have access to my host with ftp and bash via php.</p>
  
  <p>edit: clarification</p>
  
  <p>I think I need to clarify what happened. I am on a shared host, and apparently do not have write access to the directories themselves. At least the main ones such as mail and public_html. I made a backup of ~/mail with tar, but when trying to extract it extracted to ~/mail/home/mail etc, as I forgot about the full path. Now, I cannot simply untar because the path is wrong, and I cannot mv -f because I only have write access to files, not directories.</p>