Being mainly keyboard driven, Emacs offers one simple yet extremely powerful facility for automation - keyboard macros. The idea is capturing multiple series of keystrokes and then automatically executing them on demand. Here's how to start one:

C-x (

Now do a series of actions that you'd like to automate. Be careful, take your time and try to think of a clean way to achieve the first round of what you'd like to do. When you are ready:

C-x )

To execute what you've just captured:

C-x e

To execute it 42 times:

C-u 42 C-x e

This C-u NUMBER combination, known as prefix/universal argument, is a way to pass additional argument to many commands and most often causes them to be executed number of times.

Note that you don't have to execute the captured macro immediately. It stays available for execution until you define another one. To cancel capture while still recording, do the usual:

C-g

It will probably take you some practice to get used to recording composable series of actions, see here for example. Once you master it, you'll thank me for life. Imagine the possibilities, jump to some e-mail buffer, copy something, switch to a shell buffer, write some command, paste what you copied and execute, copy last line of the result, go back to the prompt, switch to some result buffer, paste there and add new line, then go back to the e-mail buffer and move to the next line. Now execute this automatically 100 times.