Multi Commander > Script
CopyFile has me Beaten
(1/1)
AlanJB:
I am trying to write a hotkeyed command to copy the file in focus to the current path. Can some kind soul please explain why this fails (the Debugger seems to have no issue with it)?
--- Code: ---@var $file = GetSourceFocusPath();
@var $path = PathGetPathPart($file);
@var $name = PathGetNamePart($file, 1);
@var $ext = PathGetFileExtPart($file);
@var $copytext = $path + $name + " - Copy" + $ext;
CopyFile($path, $copytext);
--- End code ---
Jungle:
It fails because you're trying to copy non-existing file ($copytext).
CopyFile seems to copy existing file/folder to existing path
Mathias (Author):
As Jungle said.. you send CopyFile the wrong paramters.. First is TargetName, second is SourceFile.
http://multicommander.com/docs/multiscript/functions/filesystem#copyfile
--- Code: ---@var $SourceFile = GetSourceFocusPath();
@var $path = PathGetPathPart($SourceFile);
@var $name = PathGetNamePart($SourceFile, 1);
@var $ext = PathGetFileExtPart($SourceFile);
@var $TargetFile = $path + $name + " - Copy" + $ext;
CopyFile($TargetFile, $SourceFile);
--- End code ---
AlanJB:
Thanks Jungle and Mathias: that did it.
You'd think that after 45+ years of programming I would have learnt to read the documentation more carefully... :-\
Navigation
[0] Message Index
Go to full version