I want to keep the same file names when the script is exporting each file. Tried many things but nothing worked. When it is exporting the end file name is image00001. I want it to be the same as it is in Gimp.I attempted to modify the Scheme code to retain the original filenames during export. I explored different approaches, including the use of original_filename. However, it seems that the variable is not functioning correctly, leading to errors.
Due to limitations and uncertainties in the GIMP Scheme environment and the specific challenge of saving files while preserving the original filename, finding a satisfactory solution proved difficult. The lack of certain functions or information in the GIMP Scheme API made these adjustments challenging.
(define (script-fu-save-all-images inDir inSaveType inFileName inFileNumber)
(let* (
(i (car (gimp-image-list)))
(image)
(newFileName "")
(saveString "")
(pathchar (if (equal? (substring gimp-dir 0 1) "/") "/" "\\"))
)
(set! saveString
(cond
((equal? inSaveType 0) ".jpg")
((equal? inSaveType 1) ".bmp")
((equal? inSaveType 2) ".png")
((equal? inSaveType 3) ".tif")
)
)
(while (> i 0)
(set! image (vector-ref (cadr (gimp-image-list)) (- i 1)))
(set! newFileName (string-append inDir
pathchar inFileName
(substring "00000" (string-length
(number->string (+ inFileNumber i))))
(number->string (+ inFileNumber i)) saveString))
;; Überprüfe, ob das Bild mehr als eine Ebene hat
(if (> (car (gimp-image-get-layers image)) 1)
;; Füge alle Ebenen zusammen, bevor du speicherst
(gimp-item-set-visible (car (gimp-image-merge-visible-layers image CLIP-TO-IMAGE))
TRUE)
)
;; Speichern
(gimp-file-save RUN-NONINTERACTIVE
image
(car (gimp-image-get-active-layer image))
newFileName
newFileName
)
(gimp-image-clean-all image)
(set! i (- i 1))
)
)
)
(script-fu-register "script-fu-save-all-images"
"<Image>/File/Save ALL As"
"Save all opened images as ..."
"Lauchlin Wilkinson (& Saul Goode)"
"Lauchlin Wilkinson (& Saul Goode)"
"2014/04/21"
""
SF-DIRNAME "Save Directory" ""
SF-OPTION "Save File Type" (list "jpg" "bmp" "png" "tif")
SF-STRING "Save File Base Name" "IMAGE"
SF-ADJUSTMENT "Save File Start Number"
(list 0 0 9000 1 100 0 SF-SPINNER)
)