O'Reilly logo

VBScript in a Nutshell, 2nd Edition by Ron Petrusha, Matt Childs, Paul Lomax

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

FileSystemObject.GetBaseName Method

Syntax

                  oFileSysObj.GetBaseName(Path)
oFileSysObj

Use: Required

Data Type: FileSystemObject object

A FileSystemObject object.

Path

Use: Required

Data Type: 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 and 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 of Path 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 a Path of (.) and it returns (.) for a Path of (..). It is, in other words, really a string manipulation function, rather than a file function.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required