- Save javascript as .jsx file.
- Start Photoshop with a pictures.
- Create an action (Windows->Actions->create new set->create new action)
- Press the record button to start recording
- Go to File->Scripts->Browse choose the .jsx file
- Go to File->Automate
- Select the folder of pictures you want to modify with the .jsx file, then select the action you just recorded.
This is a bit like a macro in Excel.