Returns the directory Stata is using for a temporary directory `r(tmpdir)'
tmpdir [short]
{t:itle:Description}
tmpdir is designed for programmers who want to know what directory Stata writes temp files to. This can be helpful when using the file command to write intermediary files for a program. Since spaces in directory names can cause problems for programs running, tmpdir in the Windows operating system replaces directory / subdirectory names that contain spaces, or optionally any name longer than 8 characters, with the first 6 non-space characters plus "~1" or "~2" (up to "~4"). After that it gets a bit crazy with hexadecimal replacements. tmpdir shells out to DOS and finds the short directory name that DOS has come up with, so there's no attempt to guess the short name. This makes it possible to use this program on many different versions of Windows and always get the short name right. UNIX/Linux systems tend not to have spaces in the directory designated to be the temporary directory, but tmpdir checks for spaces to make sure the temp directory does not have spaces.
Note: tmpdir can be hard coded so that it always chooses a specific directory. This can be helpful if you want to direct large files to your D: drive.
Options
short is for Windows only and it specifies that any long directory name should be shortened to 8.3 style names. Not using the short option will allow for long directory names that do not have spaces.
Examples
So if your temporary directory is: "C:\Documents and Settings\dan\Local Settings\temp"
. tmpdir returns r(tmpdir):
. return list
macros:
r(tmpdir) : "C:\Docume~1\dan\LocalS~1\temp\"
But if your temp directory is: "C:\Documents and Settings\dan_blanchette\Local Settings\temp"
. tmpdir returns r(tmpdir):
"C:\Docume~1\dan_blanchette\LocalS~1\temp\"
since "dan_blanchette" has no spaces in the name.
. tmpdir short returns r(tmpdir):
"C:\Docume~1\dan_b~1\LocalS~1\temp\"
Saved Results
The tmpdir command saves in r():
The adoedit command saves in r():
Macros r(tmpdir) Stata's temporary directory path
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) shortdir (if installed) savasas (if installed) usesas (if installed)