(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.