in reply to Script to optimize images?

Use File::Find (or File::Find::Rule) to locate the images and a module such as Image::Magick or Imager to do what you want with the images.