A default file conversion script, based on the GIMP Basic Batch tutorial, might look like this:
(define (script-fu-batch-convert pattern extension)
(let* ((filelist (cadr (file-glob pattern 1))))
(while (not (null? filelist))
(let* ((filename (car filelist))
(image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-get-active-layer image)))
(outfile (string-append filename extension)))
(gimp-message outfile)
(gimp-file-save RUN-NONINTERACTIVE image drawable outfile outfile)
(gimp-image-delete image))
(set! filelist (cdr filelist))
)
)
)
You call it as follows, for example in GIMP's Script-Fu Console:
(script-fu-batch-convert "/home/johndoe/Pictures/GIMP/tests/*.jpg" ".tif")
If you want to call it from the command line, then, depending on the platform, figuring out the proper quotes and format for the pattern might give you more or less trouble. Note that the output files will be called *.jpg.tif
This will work reasonably well for many image file formats, as gimp-file-save will be able to figure out what format to export to from the file extension
It will fail for others - in particular those that require some user input when exporting, and do not make assumptions for default values if that isn't provided. The ASCII-art plug-in is among the latter.
So, we have to be able to provide that additional input, as follows:
(define (script-fu-batch-convert-aa pattern format extension)
(let* ((filelist (cadr (file-glob pattern 1))))
(while (not (null? filelist))
(let* ((filename (car filelist))
(image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-get-active-layer image)))
(outfile (string-append filename extension)))
(gimp-message outfile)
(file-aa-save RUN-NONINTERACTIVE image drawable outfile outfile format)
(gimp-image-delete image))
(set! filelist (cdr filelist))
)
)
)
And you call that like this, for example:
(script-fu-batch-convert-aa "/home/johndoe/Pictures/GIMP/tests/*.jpg" "Text file" ".txt")
The format names are defined by the aalib library used to convert the images to ASCII art, and are a bit weird. You can see them by exporting an image to a *.txt file, the dropdown of the export dialog will look like this:
Yes, you will really have to use "For catting to an IRC channel II", if you want to use that export format.