Counting images in a folder

i’ve made a small personal photo gallery in which different days(folders of images) a specified long the top where the user can click and see what is contained within that day(folder). It’s completely dynamic to the extent that the only thing i have to specify is the number of images in each folder as a variable in a txt file (i txt file for each folder)

What i want to know is if it’s possible to dynamically count the images in a folder and use that as a variable for the number of images contained within that folder…so i dont have to have a txt file for every day with the variable in it(like i do now)

I’m sure it’s quite simple but i cant find solution anywhere.