How to parse out base file name using Script-Fu

Posted by ongle on Stack Overflow See other posts from Stack Overflow or by ongle
Published on 2009-09-06T18:09:26Z Indexed on 2010/06/06 17:12 UTC
Read the original article Hit count: 322

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about Scheme

Related posts about gimp