Sunday, April 24, 2011

Counting files

I have organized my photos this way: there's a Photos directory, under which there's one subdirectory for each year. In addition to the JPEG images, these directories also contain files like Picasa.ini. So, to find out how many pictures I have I can use the find command:

~/d/Photos % find . -type f -iname \*.jpg | wc -l
5101

This command counts the files that have .jpg file extension. Let's say I want to know the years in which I took more photos, and the years in which I took relatively lesser number of photos. That can be done using the following command: