How to get file and folder count of the first level of a job folder

Post Reply
Evan
Member
Posts: 30
Joined: Mon Feb 28, 2011 6:44 pm

How to get file and folder count of the first level of a job folder

Post by Evan »

Hello,



I'm looking to find a way to get the file and folder count of the first level of a Job folder to be able to assemble it back.



So if a job Folder contain 3 pdf and 2 folder, I want to be able to put "5" on my private data key (.NumFiles).



Actually "job.getFileCount()" don't work because it calculate all files excluding folder. Any Idea? Thanks!





function jobArrived( s : Switch, job : Job )

{

var InputJob = job.getPath();

var Filecount = job.getFileCount();

job.setPrivateData( "Ungroup.NumFiles", Filecount);

job.sendToSingle(InputJob);

}


bens
Advanced member
Posts: 253
Joined: Thu Mar 03, 2011 10:13 am

How to get file and folder count of the first level of a job folder

Post by bens »

Hi Evan,



try this:



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

var Filecount = theDir.entryList("*", Dir.Files | Dir.Dirs | Dir.NoDotAndDotDot, Dir.Unsorted ).length;

// ...

Evan
Member
Posts: 30
Joined: Mon Feb 28, 2011 6:44 pm

How to get file and folder count of the first level of a job folder

Post by Evan »

Thanks Bens, it works.
gingrasj
Newbie
Posts: 1
Joined: Fri Jan 25, 2013 3:53 am

Re: How to get file and folder count of the first level of a job folder

Post by gingrasj »

Hi
users dropped a folder contains pdf and indd

Folder = XX_20170524
Subfolder = xx02regu20170524
FIles = XX_001.pdf, XX_001.indd ...... etc .... XX_048.pdf

48 pdf and 25 ind = 73 files

The sub folders are used later to rename stuff

The number of Indd file aren't equal to number of PDF

1 - Ungroup all file and keep Ungroup private data as well (it's automatic)
2 - Assemble files to merge. *
3 - Merge all PDF on one newspaper
4 - Send to FTP

* I need to Assembling PDF only (48) for merge, Schema id Ungroup, number of files is Ungroup.NumFiles but that number include indd files

How to find how many indd files (25) on specific job folder ? if possible I can just job.getPrivateData("Ungroup.NumFiles") - x; on Number of files

x = number of indesign file for the ungrouped job

Thanks
Jack
Post Reply