Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
gimp-image-get-filename
#9
(10-08-2024, 04:00 AM)PixLab Wrote: I did not find any explanations to fetch the last in the list or the one before the last, they (websites) are all speaking about fetching/catching the first in the list and the remaining list after the first.

Well you could reverse the list. Or getting the last element of the list without reversing it:

Code:
(let* ((l '(3 45 4 "abc" "def"))
       (n (length l)))
      (list-ref l (- n 1)))

There's some ideas here but they aren't very robust:
https://stackoverflow.com/questions/1386...-script-fu

Personally I'd be doing this in Python using os:

Code:
$ python2
➤> import os
➤> help(os.path.basename)
Help on function basename in module posixpath:

basename(p)
    Returns the final component of a pathname

➤> help(os.path.splitext)
Help on function splitext in module posixpath:

splitext(p)
    Split the extension from a pathname.

    Extension is everything from the last dot to the end, ignoring leading dots.
    Returns "(root, ext)"; ext may be empty.
Reply


Messages In This Thread
gimp-image-get-filename - by PixLab - 10-07-2024, 07:36 AM
RE: gimp-image-get-filename - by Ofnuts - 10-07-2024, 11:01 PM
RE: gimp-image-get-filename - by PixLab - 10-08-2024, 04:00 AM
RE: gimp-image-get-filename - by Ofnuts - 10-08-2024, 07:22 AM
RE: gimp-image-get-filename - by teapot - 10-08-2024, 05:39 AM
RE: gimp-image-get-filename - by PixLab - 10-09-2024, 05:14 AM
RE: gimp-image-get-filename - by rich2005 - 10-09-2024, 08:37 AM
RE: gimp-image-get-filename - by PixLab - 10-09-2024, 01:14 PM
RE: gimp-image-get-filename - by pixelmixer - 11-21-2024, 04:13 PM
RE: gimp-image-get-filename - by teapot - 10-09-2024, 04:28 PM
RE: gimp-image-get-filename - by PixLab - 10-10-2024, 09:44 AM
RE: gimp-image-get-filename - by teapot - 10-10-2024, 06:48 PM
RE: gimp-image-get-filename - by PixLab - 10-30-2024, 06:37 AM

Forum Jump: