{*! 17Jan2008}-----------------------------------------------------------------
help for shortdir                                             manual:  [R] none
                                                             dialog:   none    
-------------------------------------------------------------------------------

Returns the short directory name in `r(shortdir)'

shortdir using"directory path" [, short]

Description

shortdir is designed for programmers using Stata on the Windows operating system who want to know what the short directory name (a.k.a. "8.3" name) that DOS names a directory when it contains spaces in the name or has more than 8 characters in the name. This command only works in Windows because it shells out to a DOS prompt in order to get the short directory name that Windows came up with. The formula "Take the first 6 non-space characters and add '~1'" to the directory name does not reliably work in all situations.

Examples

shortdir "c:\Documents and Settings\dan\Local Settings\temp"

returns in r(shortdir):

"c:\Docume~1\dan\LocalS~1\temp"

shortdir "c:\Documents and Settings\dan_blanchette\Local Settings\temp"

returns in r(shortdir):

"c:\Docume~1\dan_blanchette\LocalS~1\temp"

since "dan_blanchette" has no spaces in the name.

shortdir "c:\Documents and Settings\dan_blanchette\Local Settings\temp", short

returns in r(shortdir):

"c:\Docume~1\dan_bl~1\LocalS~1\temp"

since "dan_blanchette" is longer than 8 characters.

Saved Results

The shortdir command saves in r(): Macros {synopt:r(shortdir)the directory path.{p_end}

Author

Dan Blanchette The Carolina Population Center University of North Carolina - Chapel Hill, USA dan_blanchette@unc.edu

Also see

On-line: tempfile _getfilename , confirmdir (if installed) tmpdir (if installed)