Dear Danielle:
I have recently done much the same thing, perhaps slower: SET VAR vFileSpecSTRING TEXT = NULL SET VAR vFileSpecLENGTH INTEGER = NULL SET VAR vFileNameSTART INTEGER = NULL SET VAR vFileNameLENGTH INTEGER = NULL SET VAR vFileName TEXT = NULL SET VAR vFileSpecSTRING = 'C:\RIARDO_95\RIFIUTI_CLIENT\ARCHIVIO_PDF\150101-rifiuto assolutamente non pericoloso.pdf' SET VAR vFileSpecLENGTH = (SLEN(.vFileSpecSTRING)) SET VAR vFileNameSTART = ( (SLOCP(.vFileSpecSTRING,'\',-1)) + 1 ) SET VAR vFileNameLENGTH = ( (.vFileSpecLENGTH - .vFileNameSTART ) + 1 ) SET VAR vFilename = (SGET(.vFileSpecSTRING,.vFileNameLENGTH,.vFileNameSTART)) Depending on your application, you may also find great value in the "LoadFileName" and "LoadFileNamePlus" plugins which are included in R:BASE, or "LoadFileNamePlusPlus" in the Plugin Power Pack. On 2015-12-14 10:33, Kramer, Jason J wrote: > 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 > > ------------------------- > > [1] > > Questa e-mail รจ stata controllata per individuare virus con Avast antivirus. > www.avast.com [1] Links: ------ [1] https://www.avast.com/antivirus

