Page 1 of 1

Report out to email or text or excel file on files in job folder

Posted: Tue Oct 29, 2013 5:34 pm
by neecerp
Does anyone have an easy flow that will list all file names inside a folder and then combine them all as a list inside a text file or excel doc?

Report out to email or text or excel file on files in job folder

Posted: Tue Oct 29, 2013 9:31 pm
by dkelly
Here is a JS code snippet to enumerate the filenames in a directory



var dir = new Dir(job.getPath());

var entries = dir.entryList("*", Dir.Files, Dir.Name);

var requiredFiles = 0;

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

var fn = job.getPath() + "/" + entries;

}





open a file for writing



var textFile = new File("filelist.txt");

textFile.open(File.WriteOnly|File.Translate);





to write a line containing the file name



textFile.writeLine(fn);



and finally close the file



textFile.close();



To put it all together



var textFile = new File("filelist.txt");

textFile.open(File.WriteOnly|File.Translate);

var dir = new Dir(job.getPath());

var entries = dir.entryList("*", Dir.Files, Dir.Name);

var requiredFiles = 0;

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

var fn = job.getPath() + "/" + entries;

textFile.writeLine(fn);

}

textFile.close();