WONDERFUL  !
Daniele Barbieri
B.M.B. Informatica

-----Messaggio originale----- From: Stephen Markson
Sent: Wednesday, December 16, 2015 5:08 PM
To: [email protected]
Subject: [RBASE-L] - RE: extract file name from a full path

Hello,

Simplest way to do this?

If x is the var with full path and filename:

SET V vFileName=(SGET(.x,255,SLOCP(.x, '\',-1)+1))

Windows file names can't be more than 255 characters and R:Base will automatically remove any trailing spaces.


Regards,

Stephen Markson
The Pharmacy Examining Board of Canada
416.979.2431 x251

From: [email protected] [mailto:[email protected]] On Behalf Of Kramer, Jason J
Sent: December-14-15 1:33 PM
To: Stephen Markson
Subject: [RBASE-L] - RE: extract file name from a full path

Dear Daniele,
Assuming you are using a comma (,) as your delimiter and don't want to change it, then this code will get you the filename:

SET VAR voripath TEXT = 'C:\RIARDO_95\RIFIUTI_CLIENT\ARCHIVIO_PDF\150101-rifiuto assolutamente non pericoloso.pdf'
SET VAR vnewpath TEXT = (SRPL((SRPL(.voripath,',','?',0)),'\',',',0))
-- Replace all the commas with question marks because commas are valid file name character and question marks are not. If you leave commas in the path, and you are using commas as your delimiter your substring count will be thrown off.
-- Replace the back slashes with commas.
SET VAR vsubcount INTEGER = (ITEMCNT(.vnewpath))
-- Count the number of substring.
SET VAR vfilename TEXT = (SRPL((SSUB(.vnewpath,.vsubcount)),'?',',',0))
-- Return the last substring (which will always be the filename) after converting any questions marks back to commas. -- Please note that this returns the full file name, including the extension. If you don't want the extension, you will have to strip that out, but that is far more complex because a filename can contain multiple periods and extensions do not have to be only three or four characters. Thanks, Jason

Jason Kramer
University Archives and Records Management
002 Pearson Hall
(302) 831 - 3127 (voice)
(302) 831 - 6903 (fax)

From: [email protected] [mailto:[email protected]] On Behalf Of Daniele Barbieri
Sent: Monday, December 14, 2015 1:09 PM
To: Kramer, Jason J <[email protected]>
Subject: [RBASE-L] - extract file name from a full path

Hello
how can I extract the file name from a full path ?
for example in the full path
C:\RIARDO_95\RIFIUTI_CLIENT\ARCHIVIO_PDF\150101-rifiuto assolutamente non pericoloso.pdf
I need to extract the file name
150101-rifiuto assolutamente non pericoloso.pdf

TIA

Daniele Barbieri
B.M.B. Informatica

________________________________
[Image removed by sender. Avast logo]<https://www.avast.com/antivirus>


Questa e-mail è stata controllata per individuare virus con Avast antivirus.
www.avast.com<https://www.avast.com/antivirus>



---
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus


Reply via email to