*! version March 3, 2014 @ 13:37:11

Title

parsefilename -- title of command

Syntax

parsefilename
using filename
[,
options
]

Main
defext default file extension

Description

parsefilename takes a given filename and default extension and returns the extension and the filename without an extension.

Options

defext is used to declare the default extension without leading . (period/full stop/dot). So, for example a do extension would be specified via defext(do).

Remarks

parsefilename is a programmers' command which is useful for allowing using options with default extensions. It is very simple.

Example(s)

. parsefilename using `using', defext(smcl)

takes the filename in the local macro using and splits it into the base filename with any specified path and without extension, and the extension with the leading dot.

If `using' were bling, then parsefilename would return

s(sbase) : bling

s(sext) : .smcl

If `using' were bling.blang, then parsefilename would return

s(sbase) : bling

s(sext) : .blang

If `using' were /Users/fred/bling, then parsefilename would return

s(sbase) : /Users/fred/bling

s(sext) : .smcl

Stored results

parsefilename stores the following in s():

Macros

s(sbase) The base file name without any extension and including any specified path

s(sext) The proper file extension including the leading dot/period/full stop (.)

Author

Bill Rising, StataCorp

email: brising@stata.com

web: http://louabill.org