Page 1 of 1

Count Images in a directory

PostPosted: Wed Nov 27, 2013 9:59 am
by Neopasti
Hi NeoBooker..

I have a Directory(Folder) with more than thousand Images (like:Mineral1.jpg Mineral2.jpg.....Mineraln.jpg) in it.
Is there a way to count the images in these Directory(Folder) and store the result in a variable?

i would be pleased to get more information.

Thanks to all.

Re: Count Images in a directory

PostPosted: Wed Nov 27, 2013 10:06 am
by dec
Hello,

Welcome to the forum! Take a look at this recent thread. ;)

Re: Count Images in a directory

PostPosted: Wed Nov 27, 2013 10:43 am
by Neopasti
Thanks for Your answer dec..

but it's not what I want. I don't need a List.

I need the Sum of *.*jpg's in a Directory (587 or 1004 or 3756)

Is there another posibility? or its possible with a Plugin

Thank you very much

Re: Count Images in a directory

PostPosted: Wed Nov 27, 2013 10:57 am
by dec
Hello,

Take a look at this code:

Code: Select all
FileList "F:\Temp\*.jpg" "Files" "[FoundFiles]"
StrParse "[FoundFiles]" "[#13]" "[File]" "[Total]"


"[Total]" variable store the number of files founds.

Re: Count Images in a directory

PostPosted: Thu Nov 28, 2013 7:48 am
by Neopasti
Hello,

I used this code Example:
FileList "E:\NeoBook 5\MineralBookAdvanced\Mineralienbilder1\*.jpg" "Files" "[FoundFiles]"
StrParse "[FoundFiles]" "[#13]" "[File]" "[Total]"

The Variable of [Total] is always 1 but in the Folder are more than 3000 jpg Files

I have no Idea how I can check the Sum of jpgFiles in this Folder.


Thanks all

Re: Count Images in a directory

PostPosted: Thu Nov 28, 2013 8:07 am
by dec
Hello,

The code work like expected here. Note the action do not take care for subdirectories. On the other hand, "[Total]" store "0" if no one file are found, so your "1" result indicate at the least one matched file. I try listing a directory plenty of images and all work like expected.

Re: Count Images in a directory

PostPosted: Thu Nov 28, 2013 8:41 am
by Neopasti
Thanks dec....

but I think you misunderstand me.


With this code I can check is a jpg in the Folder (1) or is no jpg in the Folder (0) Is that right?

But I like to check how much jpgs in this Folder(E:\NeoBook 5\MineralBookAdvanced\Mineralienbilder1\*.jpg)

Example: in the Folder Mineralienbilder1 are 3 jpgFiles(Mineral1.jpg..Mineral2.jpg..Mineral3.jpg-->the result must be 3) copie one jpg in the Folder Mineralienbilder1
(Mineral1.jpg..Mineral2.jpg..Mineral3.jpg...Mineral4.jpg-->the result must be 4) and so on.

Sorry for my bad english

Re: Count Images in a directory

PostPosted: Thu Nov 28, 2013 10:29 am
by CN_Iceman
David's proposed code works as expected.

What you really want is the program to calculate the number of images in the folder each time there are changes? In real time?

Otherwise, every time you copy a file (or some files), you have to run the code that tells you David, you would get the number of graphs in the folder in that moment.

If what you want is that whenever there are changes in a folder, I recommend you take a look at David npNots plugin. It works like a charm!!

Greetings.

Re: Count Images in a directory

PostPosted: Thu Nov 28, 2013 10:44 am
by dec
Hello,

Jose has right. "FileList" do not return "0" or "1". On the contrary this action returns a variable containing the file paths the action found separated by carriage returns. So in fact is the "StrParse" action who take the "FileList" returns and parse it in order to get separated all the founded files and also to count the total number of founded files.

Re: Count Images in a directory

PostPosted: Thu Nov 28, 2013 10:56 am
by Gaev
Neopasti:

I can confirm that David's code works as expected ... I copied the code in your post and then pasted it in my lab pub ... just changed the folder reference.

So, after double checking that the code in your pub is exactly the same as that you posted here ...

a) use the debugger to see the values for variables [FoundFiles] and [count] ... and also any variables starting with [Names] ... like [Names1], [Names2] etc. ... one for each matching file.

b) if possible, post an image of the screenshot of Windows Explorer that shows the Address Box (E:\NeoBook 5\MineralBookAdvanced\Mineralienbilder1) ... and the right panel showing a Details View of some of the jpg files in it.

c) Tell us the version of NeoBook (mine is 5.8.4 April 2013).

Re: Count Images in a directory

PostPosted: Thu Nov 28, 2013 2:49 pm
by dec
Hello,

I feel good to add a new npDirFilesCount action to my npUtil plugin. The action do not list the files, just count it. And can do the job using a file mask and optionally looking also for subdirectories. If we need a more advanced "search engine way" my npFind plugin can come to the rescue.

Code: Select all
npDirFilesCount "[YourDirectoryPath]" "*.jpg" "True" "[TotalFiles]"


On the other hand I am proudly to announce this is the action number 150 of my npUtil plugin, number 1.013 in the total of my NeoPlugins. ;)

Hope useful for you!

Re: Count Images in a directory

PostPosted: Fri Nov 29, 2013 6:53 am
by Neopasti
The problem is solved !

Thanks to all for the comments.

Special Thank for the updatet 'npDirFilesCount action' in the 'npUtil plugin' from dec.

Thats exact what I want.

Nice Weekend to all NeoBookers

Re: Count Images in a directory

PostPosted: Mon Dec 02, 2013 11:43 am
by Leos
Hi,
maybe this can help you.
At the end you obtain the file with the list of images in the folder.
Using "files actions" you can easily get what you want.

http://www.neosoftware.com/community/viewtopic.php?f=6&t=20281

Re: Count Images in a directory

PostPosted: Wed Dec 04, 2013 12:43 pm
by Neopasti
Thanks for your reply,Leos