*! version 1.3 27 February 2015
help for extractfilenameversion 1.3 (27 February 2015)

Title

extractfilename -- extract file- and directory name from full file path

Table of contents

Syntax
Description
Remarks
Examples
Author
Saved results
Also see

Syntax

extractfilename anything

Description

extractfilename tries to split a full file path (e.g. /home/johndoe/auto.dta or C:\Users\johndoe\auto.dta)
into its directory, filename end file extension parts and returns both.

anything is the only parameter interpreted. It gives the string to be split up. If omitted, the file path of the dataset file currently opened will be used, if known to Stata.

Note that if neither anything is given nor a dataset file is openend, the procedure will exit with an error telling you to read this help file.

Depending of your input in anything, it may happen that the procedure returns an empty string for the file,
extension or directory names. The first will occur if you parse a directory name (e.g. /home/johndoe/),
the second when parsing a file name without extension (e.g. /home/johndoe/auto), the latter when parsing
a file name without full path (e.g. auto.dta); so be warned when automatically processing returned results.

Remarks

It is recommended that even if you use Windows, you use forward slashes (/) rather than backward slashes (\) for specifying
directory names. Stata will understand and there will then be no clash with other meanings for the backward slash.

This program will in any case return its results using the directory separator Stata feels to be adequate to
your operating system (`c(dirsep)'), and with a trailing separator at the end of the directory name.

This command is part of the NEPmgmt bundle, written to help creating the NEPS dataset files.

The source code of the program is licensed under the GNU General Public License version 3 or later. The corresponding license
text can be found on the internet at http://www.gnu.org/licenses/ or in gnugpl.

Examples

Split up the file path C:\Users\johndoe\auto.dta:

. extractfilename C:\Users\johndoe\auto.dta

Author

Daniel Bela (daniel.bela@lifbi.de), Leibniz Institute for Educational Trajectories (LIfBi), Germany.

Saved results

extractfilename saves the following in r():

Macros

r(filename) part of string guessed to be the filename

r(extension) part of string guessed to be the file extension

r(directory) part of string guessed to be the directory

Also see

Help: NEPSmgmt