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 ofPath
is 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 aPath
of (.)
and it returns (.)
for aPath
of(..
). It is, in other words, really a string manipulation function, rather than a file function.
Get VBScript in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.