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.

Press Ctrl+D (or ⌘D on Mac) to bookmark this page.
Version note. The generated Script-Fu targets GIMP 2.10 batch syntax, which is what most machines run and what nearly every batch tutorial assumes. GIMP 3 changed a few procedure signatures. Where that matters, the recipe says so. Check any call against Filters > Script-Fu > Console and its Procedure Browser before running it across hundreds of files.

Worth knowing:

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.

  1. Open GIMP and go to Filters, Script-Fu, then Console.
  2. Paste the whole block into the box at the bottom and press Enter.
  3. Watch the console output. A typo in a folder path is by far the most common cause of failure.
  4. 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.

Always write to a different folder than you read from. Every recipe here does that on purpose. A batch script that overwrites its own inputs has no undo, and a mistake costs you the originals.

Getting the Paths Right

System Write it like this Not like this
WindowsC:/Users/You/photosC:\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 variableA procedure name is misspelled, or it does not exist in your GIMP version.
Procedure execution failedUsually the wrong number of arguments, or the output folder does not exist.
Nothing happens, no errorThe glob matched no files. Check the folder path and the file extension case.
Opening ... failedThe output folder does not exist. GIMP will not create it for you.
Only some files processedThe 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.

Related Tools