Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Creating a folder with time and date


From   "Svend Juul" <SJ@SOCI.AU.DK>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Creating a folder with time and date
Date   Mon, 21 Aug 2006 13:45:34 +0200

Rodrogo wrote:

I've written a program that, among a whole lot of other things, logs
some output. I instruct the user to create a folder in (the fairly
generic location of) her C drive, in C:/, called "RMTestResults". I'm
wondering if anyone knows some code (if there is some) to automatically
create this folder and tag it with the time and date. Perhaps maybe also
tag it with a short description set by the user. For example, create a
folder in C:/ with name "RMTestResults-Aug-21-06 1:20pm Run 1" (where
Run 1 was specified by the user before executing the program) and save
the log of the results there.
-----------------------------------------------------

These commands will create a folder with the current date and time
included in the name:

   local D = c(current_date)
   local T = c(current_time)
   local T = subinstr("`T'",":","_",.)
   cd C:\
   mkdir "`D' `T'"
   cd "`D' `T'"

c(current_time) creates time in the format hh:mm:ss, and wontdow does
not allow : in file and folder names, hence the replacement.

Hope this helps

Svend

__________________________________________

Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6
DK-8000  Aarhus C, Denmark
Phone: +45 8942 6090
Home:  +45 8693 7796
Email: sj@soci.au.dk
__________________________________________

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index