I'm working on a script to move an external file from one directory to another.
I can't seem to get it to work. I've reduced the script to this and still no luck.
function jobArrived( s : Switch, job : Job )
{
var SourceFile = "//SPCV02/testing/FromFolder/FileToMove.txt";
var DestinationFile = "//SPCV02/testing/ToFolder/FileToMove.txt";
s.copy( SourceFile , DestinationFile );
// And move the job to the single output connection
job.sendToSingle( job.getPath() );
}
External File Copy using Javascript
Re: External File Copy using Javascript
It is good practice to make sure the separators are correct for your operating system:
This being said, why use a script? By the looks of it, what you are doing is that an incoming job triggers the copying of a file from one location to another. You can also accomplish that by using "Inject job" (note that the interesting properties are on the outgoing connection) to get FileToMove.txt into the flow and where you drop it afterwards is a matter of having an output folder with the desired path.
Code: Select all
var sourceFile = File.toNativeSeparators("//SPVC02/etc.");
Re: External File Copy using Javascript
I was using a script because I didn't know that "Inject Job" could do this.
I'm off to try it out
Thanks
I'm off to try it out
Thanks