Script-Fu Generator
Pick a job, fill in the folders, and get working batch code plus the exact command to run it. This is GIMP's answer to Photoshop Actions.
Or run it from the command line
Save this as a .py file, then run it from Filters > Python-Fu > Console with execfile("/path/to/script.py"). Python-Fu is bundled with GIMP on Windows and macOS, and is a separate package on some Linux distributions.
How to Run It
The easiest route is the console inside GIMP, because you see errors immediately.
- Open GIMP and go to Filters, Script-Fu, then Console.
- Paste the whole block into the box at the bottom and press Enter.
- Watch the console output. A typo in a folder path is by far the most common cause of failure.
- Test it on a folder of three files before you point it at three hundred.
The command line version runs GIMP without opening the interface, which is faster for large batches and can be scheduled as a cron job or a scheduled task.
Getting the Paths Right
| System | Write it like this | Not like this |
|---|---|---|
| Windows | C:/Users/You/photos | C:\Users\You\photos |
| macOS | /Users/you/Pictures/batch | ~/Pictures/batch |
| Linux | /home/you/photos | ~/photos |
Two rules cover almost every path problem. Use forward slashes even on Windows, because Script-Fu treats a backslash as an escape character. And write the full path, because the tilde shortcut is a shell feature that Script-Fu does not expand.
No spaces is a third good habit. If a folder name has spaces the script usually still works, but any command line wrapping around it gets fussy.
Common Errors and What They Mean
| Message | What it usually means |
|---|---|
| Error: eval: unbound variable | A procedure name is misspelled, or it does not exist in your GIMP version. |
| Procedure execution failed | Usually the wrong number of arguments, or the output folder does not exist. |
| Nothing happens, no error | The glob matched no files. Check the folder path and the file extension case. |
| Opening ... failed | The output folder does not exist. GIMP will not create it for you. |
| Only some files processed | The extension is case sensitive. JPG and jpg are different to the glob. |
The single most common fix is creating the output folder by hand before you run anything.
Common Questions
Script-Fu or Python-Fu, which should I use?
Script-Fu is always installed and runs from the command line without extra setup, which makes it the right choice for batch jobs. Python-Fu is far easier to read and debug if you already know Python. The generator gives you both, so pick whichever you can maintain.
Can I schedule this to run automatically?
Yes. The command line form is an ordinary shell command, so cron on Linux and macOS, or Task Scheduler on Windows, will run it on a schedule.
Where do I save a script permanently?
In your GIMP scripts folder, which the folder finder will give you. Then use Filters > Script-Fu > Refresh Scripts, and it appears in the menus.
What if my job is not in the list?
Start with the closest recipe and edit the middle. The loop that opens files, flattens, saves and closes is identical across all of them, so you only ever change the operation in the centre. The Script-Fu snippet library has more building blocks, and the Python-Fu guide covers writing your own from scratch.