Windows: Copy and Rename a file in a single step? Shortcut?
; Press F1 in Explorer to copy and manually rename the copy of the selected file
; - If the size of the selected is less 50 MB, directly in the explorer
; - otherwise using an input box (because the copying process takes more time)
#If WinActive("ahk_class CabinetWClass")
$F1::
ClipSaved := ClipboardAll
clipboard := ""
Send, ^c
ClipWait, 2
if (!ErrorLevel)
{
SplitPath, clipboard,, dir, ext, NameNoExt
If (ext = "")
{
MsgBox, No file selected
clipboard := ClipSaved
return
}
FileGetSize, size, %clipboard%, M
If (size < 50)
{
Sleep, 100
Send, ^v
Sleep, 500
; Send, {F2} ; or
SendInput, {F2}%NameNoExt% ; if you want to remove " - Copy"
}
else
{
InputBox, UserInput, Filename, Enter a name for the file,, 350, 120,,,,, %NameNoExt%
if (!ErrorLevel)
FileCopy, %clipboard%, %dir%\%UserInput%.%ext%, 1
}
}
else
MsgBox, No file selected
Sleep, 300
clipboard := ClipSaved
return
#If