# Any server script to count no. of images in a folder?

**URL:** <https://forum.kirupa.com/t/any-server-script-to-count-no-of-images-in-a-folder/42539>\
**Category:** Uncategorized\
**Created:** [February 10, 2004, 4:25am UTC](https://forum.kirupa.com/t/any-server-script-to-count-no-of-images-in-a-folder/42539 "2004-02-10T04:25:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sanjay2211](https://avatars.discourse-cdn.com/v4/letter/s/c4cdca/32.png) [@sanjay2211](https://forum.kirupa.com/u/sanjay2211)\
**Post date:** [February 10, 2004, 4:25am UTC](https://forum.kirupa.com/t/any-server-script-to-count-no-of-images-in-a-folder/42539/1 "2004-02-10T04:25:00Z")

</div>

Hi ! all

I just want to count how many images in a folder.

Can anyone give me such .asp, php or any script, which can count no. of image in a folder, so that i can call that value to flash.

For now, i m doing this with the text file, but i manually have to enter a value for no. of images in that text file. Instead of that, I want that my script should count no. images in that folder.

Plz, help me in this…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 10, 2004, 4:30am UTC](https://forum.kirupa.com/t/any-server-script-to-count-no-of-images-in-a-folder/42539/2 "2004-02-10T04:30:07Z")

</div>

why dont u just have a .txt that specifies that? its waaaaaaay easier that way for me

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 10, 2004, 4:36am UTC](https://forum.kirupa.com/t/any-server-script-to-count-no-of-images-in-a-folder/42539/3 "2004-02-10T04:36:34Z")

</div>

Thanks for Reply,

But u did not get my question well. my client will upload few images in a folder, with a script i want a value that no. of images are there.

As per that value I will have animation in flash.

So that i require a script to count automatically, I dont want a text file in which he has to enter the value for no. of images.

If, possible plz. give me the solution.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 10, 2004, 7:38am UTC](https://forum.kirupa.com/t/any-server-script-to-count-no-of-images-in-a-folder/42539/4 "2004-02-10T07:38:00Z")

</div>

here’s one in php. it returns an array with each file name as a string. anything starting with ‘.’ is ignored.

```auto

function dir_to_array($d){
	$a = array();
	if(@$handle = opendir($d)) {
		while (($file = readdir($handle)) !== false) {
			if(!preg_match("/^\./",$file)) $a[] = $file;
		};
		closedir($handle); 
		return $a;
	};
	return false;
};

```
