Multi Commander Support Forum
Multi Commander => Script => Topic started by: AlanJB on April 21, 2016, 18:34:08
-
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)?
@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);
-
It fails because you're trying to copy non-existing file ($copytext).
CopyFile seems to copy existing file/folder to existing path
-
As Jungle said.. you send CopyFile the wrong paramters.. First is TargetName, second is SourceFile.
http://multicommander.com/docs/multiscript/functions/filesystem#copyfile
@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);
-
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... :-\