Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

Is there an option or tool that will allow me to change the default naming convention for files copied into the same directory in Windows (XP) and above.

e.g. from: Copy of {name}.{ext} to: {name}.{ext}.copy


Copy of original_file.php



This would make finding/working with duplicated files much easier (they auto-sort together) and the filetype (by extension) changes thus it can't accidentally "break" something (e.g. if it were a *.java file, upon compiling I would get errors)

share|improve this question
Notepad++ Workaround: If you only deal with files containing text, as the PHP ending above implies, you could use Notepad++ with its autosave feature. See >Settings >Preferences >Tab "Backup/AutoCompletion" use "Simple backup" for only 1 backup file, use "Verbose backup" for a separate folder where files get timestamps. Also check out the plugin Autosave, this might be what you want. – Kai Noack Jun 23 '14 at 11:08
up vote 9 down vote accepted

If I understand right, you want to create duplicates of the files in the same directory. I created a .cmd file to do this via the "Send To" menu. If a name.ext.copy file already exists, it will create:

  • name.ext.copy2
  • name.ext.copy3
  • etc...

To install

  1. Go to the Start > Run... menu and type "sendto" or "shell:sendto".
  2. In the window that pops up, create a new text file.
  3. Open the new file in Notepad.
  4. Paste in the text below.
  5. Rename the text file to "Copy of.cmd" (with the quotes).

To use

  1. Select one or a group of files.
  2. Right-click on the file(s).
  3. Select the Send To... > Copy of.cmd option.

Copy of.cmd

for %%f in (%*) do call :try_copy %%f
goto :eof

if not exist "%~1.copy%2" goto :copy
call :try_next %1 %2
goto :eof

copy %1 "%~1.copy%2"
goto :eof

if "%2" == "" ( set _next=2 ) else ( set /a _next=%2 + 1 )
call :try_copy %1 %_next%
goto :eof
share|improve this answer
Thanks @kskfisher! that looks like it will a great workaround (should there not be a default way) to do this. ;-) – scunliffe Mar 11 '10 at 18:16

So I've solved that:

for %%f in (%*) do call :try_copy %%f
goto :eof

if not exist "%~d1%~p1%~n1{copy%2}%~x1" goto :copy
call :try_next %1 %2
goto :eof
if "%2" == "" call :try_next %1 %2
copy %1 "%~d1%~p1%~n1{copy%2}%~x1"

set /a _next=%2 + 1
call :try_copy %1 %_next%
goto :eof

I would guess the path problem you posted stems from how you made the contextmenu entry, because I do not have that problem.



 @="C:\\AEdNs\\nCodIP\\nCodIU\\Copy.cmd \"%1\""

I do not use MS Windows Explorer. I use various portable/freeware file managers.

All (but one) had the problem that the original script would copy the file to root "install" directory of the freeware file manager, so I added %~d1%~p1 which puts the drive\path of the original file on the output file ...

I tweaked the code in various ways for various reasons and to launch the code on any selected file(s) via the XP context menu not SendTo.

share|improve this answer
Thanks @AEN - just wondering how you "install" this to be its own context menu item vs. a child of the send to menu? – scunliffe Sep 14 '11 at 15:18
Actually, I did manage to edit the registry and add this option to the context menu... but I think it tries to create the copy/search in the directory where my *.cmd file is, not the directory of the selected file. I used the registry settings (adjusted) from here:… to add the context item. – scunliffe Sep 14 '11 at 15:36
AEN, you should register on the site, or try to keep your cookies, otherwise you won't be able to edit or answer your own post. Also, please keep it civil, what we "editors" do is – in the first place – to keep everything easy to read. As per the FAQ, the actions taken here should be clear to you. Just take it as a gentle reminder, no offense intended. – slhck Sep 15 '11 at 10:44
I like your batch code. When copying a file called file.txt repeatedly using your code via the "Send To" menu, this yields file{copy1}.txt, file{copy2}.txt, and so on. However, if someone would rather yield file(1).txt, file(2).txt, and so on, the parts of your code that show {copy%2} can be changed to (%2). I know this is an old thread, but wanted to contribute for others that may come across this page. – Trekker Sep 24 '14 at 21:28

You must log in to answer this question.

protected by nhinkle Sep 15 '11 at 10:22

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged .