Using Gimp 2.6.6 for MAC OS X (under X11) as downloaded from gimp.org.
I'm trying to automate a boring manual process with Script-Fu. I needed to parse the image file name to save off various layers as new files using a suffix on the original file name.
My original attempts went like this but failed because (string-search ...)
doesn't seem to be available under 2.6 (a change to the scripting engine?).
(set! basefilename (substring filename 0 (string-search "." filename)))
Then I tried to use this information to parse out the base file name using regex but (re-match-nth ...)
is not recognized either.
(if (re-match "^(.*)[.]([^.]+)$" filename buffer)
(set! basefilename (re-match-nth orig-name buffer 1))
)
And while pulling the value out of the vector ran without error, the resulting value is not considered a string when it is passed into (string-append ...)
.
(if (re-match "^(.*)[.]([^.]+)$" filename buffer)
(set! basefilename (vector-ref buffer 1))
)
So I guess my question is, how would I parse out the base file name?
GIMP 2.6.6 Windows Vista SP2
Extract the basename of the original filename without its extension.
Error: eval: unbound variable: re-match-nth
GIMP menu "Filters" > "Script-Fu" > "Console"
In the input box, paste the following Script-Fu definition of function then hit the ENTER key:
(define (filename-basename orig-name)
(car (strbreakup orig-name "."))
; Nimmzo 09/09/30: the string split function strbreakup is defined
; in the compatibility file from SIOD to TinyScheme:
; C:\Program Files\GIMP\share\gimp\2.0\scripts\script-fu-compat.init
) ; end filename-basename
To test the function, enter:
(filename-basename "screen.xcf")
The Script-Fu Console answers:
"screen"