Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have a folder to which a lot of people copy files. Instead of over writing the existing file on the folder, I would like to rename the original file first, and then copy the new file.

Example: If I copy a file myFile.txt (which is already present in the folder), it should save the existing file as myFile_backup.txt and copy the new file as myFile.txt.

Is this possible?

share|improve this question
What would happen the following time the back up run - would you want to add a number for each time the back up run (eg myFile01.txt, myFile02.txt) - you will end up with a massive folder. – Dave Sep 24 '12 at 8:56
Hi Dave, Thanks a lot for your response. I just need to have one backup version. At any instance after the 1st copy, I will only have myFile.txt and myFile_backup.txt. Thanks! – Anand Sep 24 '12 at 9:12
So, on the third time the back up runs (where you have myFile and myFile_backup) what happens. Does myFile overwrite myFile_backup ? – Dave Sep 24 '12 at 9:22
Yes. myFile overwrites myFile_backup. I just want to have one previous version of the file as a backup. Also, is this function valid only for a session? When I exit and comeback, it tells me copyFileToFolder does not exist. I am very new to this thing so sorry for asking such basic questions. – Anand Sep 24 '12 at 9:33
The default behavior for Windows 7 is to prompt the user what to do when a file with the same name appears in a folder being copied to. My suggestion is to inform everyone of this behavior. – Ramhound Sep 24 '12 at 10:58

This is possible, however you will need to create a batch file (could be placed inside this folder you mention) that people would drag-and-drop file onto, which will do the following:

  1. Gets the drag-and-dropped file as an argument/parameter that the batch file can use.
  2. Checks for files with the same name as the dropped file
  3. If the dropped file's name is unique, then save the file
  4. If the dropped file is not unique, then first rename the conflicting file to filename_backup.ext, then save the file

Doing the above, you will achieve what you are looking for. Of course this means you will have to educate/force all users of that folder to always drag-and-drop files onto this special batch file.

You could place this batch file at the root of a folder and then save the actual files to another sub-folder so users will immediately notice that they have to drop the file onto the batch file.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.