Syntax
FileNameInfo$(Filename$, InfoType)
Remarks
Returns the part of Filename$ specified by InfoType.
Argument | Explanation |
Filename$ | The path, if specified, and filename of a document. Though the path must exist, the filename does not have to be the name of an existing document. If the path does not exist, an error occurs. |
Argument | Explanation |
InfoType | The part of Filename$ to return: 1 The full path and filename. In Windows, for example, FileNameInfo$(FileName$(), 1) might return "C:\DOCUMENT\TEST.DOC." If Filename$ does not include a path, FileNameInfo$() returns a path made up of the current folder and Filename$, even if such a file does not yet exist. 2 The filename only, if Filename$ is located in the current folder; otherwise, the full path and filename. 3 The filename. On the Macintosh, for example, FileNameInfo$("HD:DOCUMENTS:TEST DOC", 3) returns "TEST DOC." 4 The filename without a filename extension. In Windows, for example, FileNameInfo$("C:\DOCUMENT\TEST.DOC", 4) returns "TEST." On the Macintosh, setting InfoType to 4 returns the whole filename (same as setting InfoType to 3). 5 The full path, including the trailing backslash (\) (Windows) or colon (:) (Macintosh). On the Macintosh, for example, FileNameInfo$("HD:DOCUMENTS:TEST DOC", 5) returns "HD:DOCUMENTS:." 6 In Windows, returns the universal naming convention (UNC) network path and filename. For example, if TEST.DOC is located on a server with the network share name \\DOCUMENT\PUBLIC, then FileNameInfo$("D:\DOCUMENT\TEST.DOC", 6) returns "\\DOCUMENT\PUBLIC\DOCUMENT\TEST.DOC." On the Macintosh, returns a string that begins with the zone and computer name. For example if INSTRUCTIONS is located in a shared folder named ART TOOLS, FileNameInfo$("ART TOOLS:INSTRUCTIONS") might return "PUBLIC:TOOLS:ART TOOLS:INSTRUCTIONS," where PUBLIC is the zone and TOOLS is the computer name. If Filename$ is not located on a network share, the full path and filename are returned. |
Example
This Windows example uses FileNameInfo$() to change the filename extension of all the files in the current folder with the extension .DOC to .RTF and then saves the files in rich-text format (RTF):
file$ = Files$("*.DOC") While file$ <> "" FileOpen .Name = file$ noExtension$ = FileNameInfo$(file$, 4) FileSaveAs .Name = noExtension$ + ".RTF" , .format = 6 FileClose 2 file$ = Files$() Wend
See Also
FileName$(), FileNameFromWindow$()