Discussion:
Filepath column data: basename
(too old to reply)
Sarat Sreepathi
2020-11-21 00:18:07 UTC
Permalink
Hello:

I have a data file where one of the columns contains full path names. Is there a trick to getting a basename from that field? Any builtins for other transformations on that field?

Appreciate any pointers.
Thanks,
Sarat.
Karl Ratzsch
2020-11-21 09:35:52 UTC
Permalink
Post by Sarat Sreepathi
I have a data file where one of the columns contains full path names. Is there a trick to getting a basename from that field? Any builtins for other transformations on that field?
Appreciate any pointers.
Thanks,
Sarat.
Recursion: ;)

basen(fullp) = (a = strstrt(fullp,'\'), a == 0 ? fullp : basen(
substr(fullp,a+1,strlen(fullp) ) ) )

pr basen('helo')
pr basen('helo\halo')
pr basen('helo\halo\holo')

In the same way you can delete (possibly multiple) .extensions from
the filename.
Chris Elvidge
2020-11-21 10:50:56 UTC
Permalink
Post by Karl Ratzsch
Post by Sarat Sreepathi
I have a data file where one of the columns contains full path names.
Is there a trick to getting a basename from that field? Any builtins
for other transformations on that field?
Appreciate any pointers.
Thanks,
Sarat.
Recursion: ;)
basen(fullp) = (a = strstrt(fullp,'\'), a == 0 ? fullp : basen(
substr(fullp,a+1,strlen(fullp) ) ) )
pr basen('helo')
pr basen('helo\halo')
pr basen('helo\halo\holo')
In the same way you can delete (possibly multiple) .extensions from the
filename.
Can you use a function?
e.g. f=system("basename ".fullpath)
--
Chris Elvidge, England
Loading...