Change "copy of" when copying in same directory

Suggestions and feature requests.
Locked
Message
Author
elmarz
Posts: 2
Joined: 29.10.2008, 08:31

Change "copy of" when copying in same directory

#1 Post by elmarz » 04.08.2009, 10:34

Is there the possibility to change the name of a file copied in the sam directory.

example:

origin name: test.txt
copied name: test_1.txt

Thanks

User avatar
Dreamer
Site Admin
Posts: 6444
Joined: 19.08.2007, 23:40

#2 Post by Dreamer » 06.08.2009, 00:10

I don't it's possible in FC, but you can use Multi rename feature to easily rename all files at once, as workaround, just select all files, press F2 - then create a profile (just the first time) and you will be able to rename such files very easy - select the files, F2 and select profile (or click the toolbar button menu item with the profile name) and press Enter.

W4tch3r
Posts: 10
Joined: 04.10.2007, 05:47

#3 Post by W4tch3r » 06.08.2009, 08:39

I wanted this so badly, I wrote an autoit script that does it, compiled it to and exe, drew an icon and stuck it in a toolbar. I now have my own "copy" button that copies the file. The new name is like this:

old name: AAA.xxx
new name: AAA --copy--.xxx

its not perfect. Doesn't work on folders for example. But its getting there (I patch it when I find bug). Here is how you integrate it into FC:

Program: FC File Copy.exe
Start Folder: %ActivDir%
Parameter: "%Activeitem%"
Icon: Icon - file copy.ico

I drew the icon, and notice the quotes around "%ActiveItem%". Here is the script. Feel free to try it but use at your own risk, and try it in a test folder first!!!

// AutoIT script for copying a file and appending a string to the new filename
Opt("TrayIconHide", 1) ;0=show, 1=hide tray icon

; Show message if no parameters were given
if $CmdLine[0] = 0 Then
MsgBox(0,"FC File Copy", "Copies source file to the same folder: FC File Copy <fname>")
Exit
Endif

$fname_main = ""
$fname_ext = $CmdLine[1]
$index = StringInStr($fname_ext, ".")
$copystr = " --Copy--"

; find last "." before which we want to add "--copy--"
While $index > 0
$fname_ext = StringTrimLeft($fname_ext, $index)
;MsgBox(0,"Debug", "fname_ext: " & $fname_ext & ", index: " & $index)
$index = StringInStr($fname_ext, ".")
Wend
$fname_main = StringTrimRight($CmdLine[1], StringLen($fname_ext) + 1)

; Print out filename and extension. Debug code to check the above 2 bits
;Msgbox(0,"Debug","name: " & $fname_main & " ext: " & $fname_ext)

; Need also to handle the case where there was no extension at all (put the --copy-- at the very end). This loop will try up to 10 times to create a copy before it gives up. If "xxx --copy--" already exists, it will try "xxx --copy--1", "xxx --copy--2" etc

If StringLen($fname_main) = 0 then
If Not FileCopy($CmdLine[1], $fname_ext & $copystr) then
for $i = 1 to 10
if FileCopy($CmdLine[1], $fname_ext & $copystr & $i) then
Exit
Endif
Next
Msgbox(0,"FC File Copy", "Sorry Can't copy file. Last attempt: " & $fname_ext & $copystr & $i)
Endif
Else
If Not FileCopy($CmdLine[1], $fname_main & $copystr & "." & $fname_ext) then
for $i = 1 to 10
if FileCopy($CmdLine[1], $fname_main & $copystr & $i & "." & $fname_ext) then
Exit
Endif
Next
Msgbox(0,"FC File Copy", "Sorry Can't copy file. Last attempt: " & $fname_ext & $copystr & $i & "." & $fname_ext)
Endif
Endif

Locked

Who is online

Users browsing this forum: No registered users and 4 guests