Product SiteDocumentation Site

7.4.31. FILESPEC


>>-FILESPEC(option,filespec)-----------------------------------><

Returns a selected element of filespec, given file specification, identified by one of the following option strings:
Drive
The drive letter of the given filespec. Only available on Windows. On Unix, it returns a null string ("").
Path
The directory path of the given filespec.
Location
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
The file name of the given filespec.
Extension
The extension portion of the filespec file name.
If filespec cannot find the requested information, then the FILESPEC function returns a null string ("").

Note

Only the initial letter of option is needed.
Here are some Windows examples:

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"      */