count files in a folder
Copy link to clipboard
Copied
I want to count the files in a volume. This will tell me how many pictures that i have then as certain actions happen it will automatically add them up for me. First step is finding the corect syntax for the items.
Copy link to clipboard
Copied
OK. This is what I am looking for
app.document.thumbnail.children
now I just have to count these little children.
Copy link to clipboard
Copied
alert(app.document.thumbnail.children.length);
Copy link to clipboard
Copied
I ended up using this but I am sure its the same thing.
var myItems =app.document.thumbnail.children;
for (var i=0; i<myItems.length; i++){}
alert(i-2);
I am slowly plucking away at this calculator thing.
I am subtracting two because I have two pdf files I don't want to count.
Yep just tried it. It works.
Copy link to clipboard
Copied
alert( app.document.visibleThumbnailsLength );
Copy link to clipboard
Copied
Nice. Very stealthy Mark I like it.
Copy link to clipboard
Copied
The problem with the above methods is that they could be counting folders/text/exe files etc.
You can control what you want to count with something like this...
app.document.deselectAll();
alert(app.document.getSelection("jpg,pdf,tif").length);
The above will only count jpg, pdf and tif files.
Copy link to clipboard
Copied
What was your intent with this script Bridge already has a built-in file type counter? My desktop is very tidy just now…!!!!
Copy link to clipboard
Copied
The intent is to inventory the images for each folder I view and inhance. There are multiple jpgs in the folder along with two pdfs a high and low res. The low res is droped to a hot folder after the low res pdf is droped the script would count the jpgs. Then when I move on to the next folder and do the same thing it adds it to my exsisting tally. Each time subtracting the two pdf files from the tally. Or if you can identify the jpgs you would not have to subtract.

