Page 1 of 1

regExp

Posted: Thu May 19, 2011 11:13 am
by caio
I

I have to copy files from directory but i know only first segment of file's name



Can I use the RegExp on "createPathWithName"?



Somethings like this:





var ThePath = job.createPathWithName("FirstSegmentOfTheName" + /.{n,}/);



s.copy( "/My_Disk/folder/FirstSegmentOfTheName" + /.{n,}/, TheSourcePath);



Tank you for any suggestions....





caio guardigli

Centro Stampa Digitalprint srl

Rimini - Italy

regExp

Posted: Thu May 19, 2011 3:07 pm
by dkelly
You can't use regular expressions since those functions take String args.



You can do something like this:





var theDirName = "/My_Disk/folder";

var myDir = new Dir(theDirName);

var theFiles = myDir.entryList("FirstSegmentOfTheName*", Dir.Files, Dir.Name);

var i;

for (i=0; i < theFiles.length; i++) {

var theDestPath = job.createPathWithName(theFiles);

s.copy( theDirName + "/" + theFiles, theDestPath );

}





Dwight Kelly

Apago, Inc.

dkelly@apago.com

regExp

Posted: Fri May 20, 2011 10:23 am
by caio
tank you!



In the "Dir Class" there is the solution....