How to traverse directory structure and sum size of files?

How do I write a bash or ruby or perl or groovy script to print all the files in my directory tree that are one-to-two years old, the size of each file, and the sum of file sizes and then delete them?

I was using

find . -atime +365 -exec rm '{}' \; 

but the problem was that I could not tell if it was hung because it took a very long time. There are a half million files in this directory tree. I can't figure out how to enhance this to give me a sum of the space freed up with the deletes and give me some updates as to what is going on so I know it is not hung.

How do I tell find to get files with in a set of date ranges?

Thanks,
Siegfried

Half a million files can take their time. Add a -print in front of your -exec to see if it's stuck.

---------- Post updated at 11:15 AM ---------- Previous update was at 09:54 AM ----------

You should also use the -mtime option instead of -atime since -atime timestamp will be updated even if you had just a reading action on the file. -mtime resembles to the date you see when you do a ls -l.
To express a "starting" and "ending" time you can also combine 2 -mtime like:

find . -mtime -730 -mtime +365 -print -exec rm '{}' \;

which should delete all files older than 1 year but not older than 2 years ie. the year before the last year.
When experimenting with this, leave out the -exec rm so you do not accidentally delete things if something is not according to your needs.

Now how do I sum the sizes of the files as I delete them?

You could simply run this with a ls -la instead of a rm in the -exec part at 1st and sum them up with shell arithmetics or awk...
After that run the same with rm. Or build a construct with pipe and xargs etc. to do both in one line.

sum=0
for k in `find . -mtime -730 -mtime +365 -exec ls -l {} \+ | awk '{print $5}'`
do
   sum=$((sum+k))
done
echo "Total file size is $sum"

Another untested version of the above.

find . -mtime -730 -mtime +365 -exec ls -l {} \+  | awk '{  x += $5  } END {print "Total file size is "x}'