[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: Creating a folder with time and date
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'",":","_",.)
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
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
* For searches and help try: