Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Chris Elvidge Newsgroups: comp.graphics.apps.gnuplot Subject: Re: Filepath column data: basename Date: Sat, 21 Nov 2020 10:50:56 +0000 Organization: A noiseless patient Spider Lines: 33 Message-ID: References: <2f8a72a5-b4c1-40d4-ae13-8634463cd5bcn@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 21 Nov 2020 10:51:14 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="1e51784f63afb862fc9099591cd1c26d"; logging-data="13027"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1913c4UI1KV4waU3Nakggp8P0R/SgZpTc0=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 Lightning/5.4 Cancel-Lock: sha1:23ZbSSuqZEZXYFRzrdcqgYpUCN8= In-Reply-To: Content-Language: en-GB Xref: csiph.com comp.graphics.apps.gnuplot:4375 On 21/11/2020 09:35 am, Karl Ratzsch wrote: > Am 21.11.2020 um 01:18 schrieb Sarat Sreepathi: >> 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. >> > > 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