To insert a routine into your script that will iterate multiple documents:

Place the cursor on a blank line in the script.

Control-click in the selected area.

Choose Iterate Items, and then choose the type of routine you want.
Files of Chosen Folder: Creates a repeat loop for processing each document file of a chosen folder.
Images of Chosen Folder: Creates a repeat loop for processing each image file of a chosen folder.
Items of Finder Selection: Creates a repeat loop for processing each item selected in the Finder.