Any option to change Windows XP default Copy Here naming from "Copy of {name}.{ext}" to "{name}.{ext}.copy"

9

5

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

Currently:

original_file.php
Copy of original_file.php

Desired:

original_file.php
original_file.php.copy

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)

scunliffe

Posted 2010-03-10T16:46:37.967

Reputation: 1 508

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 – 2014-06-23T11:08:34.450

Answers

9

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

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

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

:try_next
if "%2" == "" ( set _next=2 ) else ( set /a _next=%2 + 1 )
call :try_copy %1 %_next%
goto :eof

mskfisher

Posted 2010-03-10T16:46:37.967

Reputation: 942

Thanks @kskfisher! that looks like it will a great workaround (should there not be a default way) to do this. ;-) – scunliffe – 2010-03-11T18:16:33.800

0

So I've solved that:

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

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

:try_next
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.

[HKEY_CLASSES_ROOT\*\shell]

[HKEY_CLASSES_ROOT\*\shell\AllF01]
 @="C&@py"

[HKEY_CLASSES_ROOT\*\shell\AllF01\command]
 @="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.

AEN

Posted 2010-03-10T16:46:37.967

Reputation: 1

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 – 2014-09-24T21:28:40.880

Thanks @AEN - just wondering how you "install" this to be its own context menu item vs. a child of the send to menu? – scunliffe – 2011-09-14T15:18:45.220

1

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: http://superuser.com/questions/65105/how-to-add-a-windows-explorer-context-menu-item-with-custom-functionality to add the context item.

– scunliffe – 2011-09-14T15:36:32.007

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 – 2011-09-15T10:44:56.577