Re: Copying files with a Macro?

Posted by Michael Schmid on
URL: http://imagej.273.s1.nabble.com/Copying-files-with-a-Macro-tp3689619p3689620.html

Hi Adam,

neither Java nor the ImageJ macro language has a File.copy method.

Method (1)
You can either open it and save it somewhere else in a macro.

Method (2)
Use the 'exec' command.
I have not tried, but it should be something like the following:
On unix-style and Mac:
   exec("cp", oldPath, newPath);
and on Windows
   exec("cmd", "/c", "copy", , oldPath, newPath);

Method (3)
Write a plugin that has a static method and use the 'call' macro  
function. The code of the plugin could be similar to that of
   http://www.java2s.com/Code/Java/File-Input-Output/FileCopyinJava.htm
except that the static method should not be named 'main' and should  
not use a String array 'args' but have two Strings as an argument.

Michael
________________________________________________________________

On 21 Jan 2010, at 10:46, Adam Cliffe wrote:

> I'm trying to get a macro to make a copy of a few XML files while it
> is processing images.
>
> I've tried using: File.rename(path1, path2);
>
> But this removes the original. Does anyone know a good trick for
> copying a file? Or do I just need to open it, save it somewhere else
> and close it?
>
> thanks
>
> Adam
>
>
> Dr Adam Cliffe
> Research Scientist, Rorth Lab
>
> Institute of Molecular and Cell Biology
> 61 Biopolis Drive
> Proteos
> Singapore 138673
>
> tel: +65 6586 9731
>
>
>
>
>
>
>
>
>
> Note: This message may contain confidential information. If this  
> Email/Fax has been sent to you by mistake, please notify the sender  
> and delete it immediately. Thank you.