Name
FileSystemObject.GetBaseName Method
Syntax
oFileSysObj.GetBaseName(Path)
-
oFileSysObj Use: Required
Data Subtype: FileSystemObject object
Any object variable returning a FileSystemObject object.
-
Path Use: Required
Data Subtype: String
A path specifier.
Return Value
A string containing the last element in
Path.
Description
Returns the name of the last path component, less any extension.
Rules at a Glance
The file extension of the last element in
Path isn’t included in the returned
string.
Programming Tips & Gotchas
GetBaseName doesn’t verify that a given file or folder exists in
Path.In stripping the “file extension” and returning the base name of
Path, GetBaseName has no intelligence. That is, it doesn’t know whether the last component ofPathis a path or a filename. If the last component includes one or more dots, it simply removes the last one, along with any following text. Hence, GetBaseName returns a null string for aPathof (.)and it returns (.)for aPathof(..). It is, in other words, really a string manipulation function, rather than a file function.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access