Get path or filename from full path

Syntax

s.getpath([file] [append])
s.getfilename([file] [ext])

 

Parameters

s - str variable.

file - full path of a file or folder. Default: s.

append - some string to append. Use "" to remove "\".

ext - if nonzero, get filename with extension.

 

Remarks

getpath extracts path part from file.

getfilename extracts filename part from file.

 

QM 2.3.4. Supports file streams, like "c:\a\b.txt:stream1:$DATA".

 

Tips

There are many Windows API functions that can be used to work with paths and URLs. For example, PathFindExtension. Documented in MSDN Library.

 

Example

str s1.getpath("c:\folder\test.txt")
str s2.getfilename("c:\folder\test.txt")
str s3.getfilename("c:\folder\test.txt" 1)
 now s1 is "c:\folder\", s2 is "test", s3 is "test.txt"