Product Site

7.4.31. FILESPEC

Returns a selected element of filespec, given file specification, identified by one of the following option strings. Only the capitalized option letter is needed; all characters following it are ignored.
Drive

On Windows, returns the drive letter of the given filespec. On Unix-like systems, returns a null string ("").
Path

Returns the directory path of the given filespec.
Location

Returns the full location portion of the given filespec. On Windows, this will include both the Drive and Path information. On other platforms, this returns the same result as the Path option.
Name

Returns the file name of the given filespec.
Extension

Returns the extension portion of the filespec file name.

If filespec does not contain the requested information, FILESPEC returns a null string ("").

Example 7.43. Builtin function FILESPEC
thisfile = "C:\WINDOWS\UTIL\SYSTEM.INI"
say FILESPEC("drive",thisfile)     /* says "C:"              */
say FILESPEC("path",thisfile)      /* says "\WINDOWS\UTIL\"  */
say FILESPEC("location",thisfile)  /* says "C:\WINDOWS\UTIL\"  */
say FILESPEC("name",thisfile)      /* says "SYSTEM.INI"      */
say FILESPEC("extension",thisfile) /* says "INI"      */
part = "name"
say FILESPEC(part,thisfile)        /* says "SYSTEM.INI"      */