1

I often copy and paste a file into the same folder (quickly pressing Ctrl+C, then Ctrl+V).

It seems the default Windows behaviour is to rename the duplicate file as "filename - Copy.extension".

Instead, I'd like to have the duplicate file immediately "ask" for a new name - have the rename box grab focus so I can rename the file and avoid conflict.

Is this possible?

1
  • 1
    Should be possible with a custom AutoHotkey script, but it'll have to be kept running in the background.
    – Karan
    May 10, 2015 at 4:21

2 Answers 2

0

Ctrl+C, Ctrl+V, F2

That's what I do. For when you copy from a different folder this doesn't look like it's possible out of the box.

0

Thanks to @Karan for the AutoHotkey idea in the comment to the question.

The following script gets the filename from the currently selected file in Explorer, shows a message box to enter the new name and then creates a copy of the file. I haven't tested what happens if you select multiple files. Adapt to your needs:

#Requires AutoHotkey v2.0-
#Warn
#SingleInstance

#HotIf WinActive("ahk_exe explorer.exe")

^q::DuplicateFile(GetSelectedFilePaths())

GetSelectedFilePaths() {
    winClass := WinGetClass( "ahk_id" . hWnd := WinExist("A"))
    if (winClass ~= "Progman|WorkerW|(Cabinet|Explore)WClass") {
        shellWindows := ComObject("Shell.Application").Windows
        if (winClass ~= "Progman|WorkerW")
            shellFolderView := shellWindows.Item( ComObject(VT_UI4 := 0x13, SWC_DESKTOP := 0x8) ).Document
        else {
            for window in shellWindows
                if (hWnd = window.HWND) && (shellFolderView := window.Document)
                    break
        }
        result := ""
        for item in shellFolderView.SelectedItems
            result .= (result = "" ? "" : "`n") . item.Path
        if !result
            result := shellFolderView.Folder.Self.Path
    } else {
        ClipSave := ClipboardAll
        Clipboard := ""
        SendInput "^c"
        ClipWait 2
        result := Clipboard
        Clipboard := ClipSave
    }
    Return result
}

DuplicateFile(Source, Overwrite := false) {
    SplitPath Source, &name, &dir, &ext, &name_no_ext, &drive

    IB := InputBox("Please enter the new name:", "Duplicate file", "w200 h80", name_no_ext)
    if IB.Result = "OK"
        FileCopy Source, dir "\" IB.Value "." ext, Overwrite
}

I got the code for the explorer script from the AutoHotkey forum, but adapted it to v2.

While this hasn't been the question, also notice that it is possible to change the default rename template (i.e. the "- Copy"), editing HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\NamingTemplates\CopyNameTemplate (String) in the registry. The default is %s - Copy, where %s is the old name. This is described here.

You must log in to answer this question.

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