News:

MultiCommander v16.6 is released!

Main Menu

CopyFile has me Beaten

Started by AlanJB, April 21, 2016, 18:34:08

Previous topic - Next topic

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)?

@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);


Jungle

#1
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

@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);

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...  :-\