Skip to content

Get the filename from the given path

2 messages · Rantony, William Dunlap

#
Q.
A.
But this is much like saying
   x <- "MyFile.txt"
will give you the desired output - where did the 13 come from?

Use basename() for a general solution.
  > basename(FPath)
  [1] "MyFile.txt"
dirname(FPath) gives you the directory that FPath is in in.

(To other responders, those who don't know that all caps means shouting
probably don't know that the answer '?basename' means to type that into
R to look at the help file for the basename function.)

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com