Author Topic: MultiScript: CopyFile - How to copy to the same dir with the new name?  (Read 4180 times)

Jungle

  • Contributor
  • VIP Member
  • *****
  • Posts: 510
  • Old Skull
    • View Profile
I want to copy some file to the same dir with a new name (manually specified, no autorename). But CopyFile function accepts only path as a target param.

Is it somehow possible to achieve the goal? If no, maybe enhance CopyFile with an additional param or implement a new function CloneFile?

Ulfhednar

  • Contributor
  • VIP Member
  • *****
  • Posts: 503
    • View Profile
You can click & drag/release in the same dir & it shows copy with new name as option on the dialog.  (Which you know :) )

Mathias probably needs to add this existing drag functionality to the MS command set, should be possible I hope.   

« Last Edit: December 09, 2022, 18:31:22 by Ulfhednar »

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4271
    • View Profile
    • Multi Commander
I want to copy some file to the same dir with a new name (manually specified, no autorename). But CopyFile function accepts only path as a target param.

Is it somehow possible to achieve the goal? If no, maybe enhance CopyFile with an additional param or implement a new function CloneFile?

That should be able to do that is Script..
So you mean if you set target name like  CopyFile ("C:\NewFile.txt" , C:\MyFile.txt" , "NODIALOG, OVERWRITE_ALL" );
It does not work ?


Jungle

  • Contributor
  • VIP Member
  • *****
  • Posts: 510
  • Old Skull
    • View Profile
So you mean if you set target name like  CopyFile ("C:\NewFile.txt" , C:\MyFile.txt" , "NODIALOG, OVERWRITE_ALL" );
It does not work ?

Code: [Select]
# Error "Source and Target file are the same. Cannot copy a file to itself"
# (err.png)
@var $res = CopyFile("d:\\temp\\abc.txt", "d:\\temp\\1.txt", "NODIALOG")

# $res = 1, but file is not copied
$res = CopyFile("d:\temp\abc.txt", "d:\temp\1.txt", "NODIALOG")

# Shows copy dialog with wrong destination path (err2.png),
# but produce no error, file is not copied
$res = CopyFile("d:\temp\abc.txt", "d:\temp\1.txt")

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4271
    • View Profile
    • Multi Commander
Code: [Select]
@var $res = CopyFile("d:\\temp\\abc.txt", "d:\\temp\\1.txt", "NODIALOG") should work.. something must have broken.. I will investigate and see If I can fix that

AlanJB

  • VIP Member
  • *****
  • Posts: 432
  • VERY old Programmer
    • View Profile
I can confirm the same failures in MC 11.6(build 2845).