Gimp-Forum.net
Modifying DivideScannedImages Batch-Mode - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP)
+---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions)
+---- Thread: Modifying DivideScannedImages Batch-Mode (/Thread-Modifying-DivideScannedImages-Batch-Mode)



Modifying DivideScannedImages Batch-Mode - waver - 06-14-2025

Hello,

since a while I've been using the (I think very good) script "https://github.com/FrancoisMalan/DivideScannedImages"

But one thing isn't optimal for me in Batch-Mode: all the picture that were processed get the name "Crop..." with a number.
It would be more useful to have (also) the original file name in the output name.

In Batchmode there already exists the variable "filename", but when I put it in in the line with the output


Code:
(set! newFileName (string-append targetDir pathchar filename inFileName 

then I get "Error: eval: unbound variable: filename "


I supposed the problem is that the variable is not declared, so I put it in the line for the batch-part:


Code:
(define (script_fu_BatchDivideScannedImages inSourceDir inLoadType inSquareCrop inPadding inLimit inDeskew inAutoClose inThreshold inSize inDefBg inBgCol inCorner inX inY inSaveInSourceDir inDestDir inSaveType inJpgQual inFileName inFileNumber filename)

But than I get "Error: not enough arguments"

What I'm doing wrong? 

PS.: I'm using Gimp 2.10.36 under Linux Mint 64bit


RE: Modifying DivideScannedImages Batch-Mode - rich2005 - 06-14-2025

yeah, script-fu death by a thousand parentheses

Maybe a starting point adding a line to set inFileName to the image name. about line 207

Code:
(set! inFileName  (car (gimp-image-get-name img)))

            (set! newFileName (string-append targetDir pathchar inFileName
                                     (substring "00000" (string-length (number->string (+ inFileNumber numextracted))))
                                     (number->string (+ inFileNumber numextracted)) saveString))

Unfortunately that uses the full name including the file extension, so a chunk of code needed to parse the file name - maybe somebody can advise.

That for example on a couple of png test images gives
a.png -> a.png00001.jpg a.png00002.jpg
b.png -> b.png00003.jpg b.png00004.jpg b.png00005.jpg