Subj : Re: CMDTIME
To : Robert Bull
From : Bob Swift
Date : Sun Apr 20 2003 07:29 pm
-=> Robert Bull wrote to Bob Swift <=-
RB> I'm still not getting what I wanted/expected, but, I'm not sure that's to
RB> do with CMDTIMEW. It might be something to do with the way COMMAND.COM
RB> passes parameters, or maybe, the way it deals with zero-byte files as I
RB> used for testing (only just thought of that one). Viz.:
RB> cmdtimew ren spar001.htm @
[email protected]
RB> File not found - spar001.htm
That's because DOS is confused and doesn't know what error message to display.
The problem is that you're trying to rename the file to a name which includes a
colon. That's still an absolute no-no under DOS.
RB> cmdtimew echo @
[email protected]
RB> 2003-04-17_16:03:01.htm
RB>
RB> as expected, and how I wanted to rename the file.
And worked because it was displaying to the screen, not renaming with an
included colon.
RB> Also noticed the following behaviour WRT quote marks;
RB>
RB> cmdtimew echo "@
[email protected]"
RB> 2003-04-17_16:03:18.htm
RB>
RB> cmdtimew echo ""@
[email protected]""
RB> 2003-04-17_16:03:24.htm
RB>
RB> cmdtimew echo """@
[email protected]"""
RB> "2003-04-17_16:03:31.htm"
RB>
RB> i.e., if you want to echo one double-quote, you have to stack three. Not
RB> sure if that means much...
I actually found that really interesting, and can (sort of) explain it. When
the original parameters are passed to CMDTIME, DOS will remove the quotes (one
set) around the parameter. If you are only using one set of quotes, they never
actually get passed to CMDTIME, however the string enclosed within will get
passed (including null strings and strings with spaces). After CMDTIME does
its substitutions on each parameter, it checks to see whether the parameter is
either a null string or contains spaces. If it meets one of these two
criteria, then the parameter will be enclosed in quotes when passed to the
system command processor. For example, if you enter:
cmdtime echo @c
you will find that the resulting date and tme information will be echoed to the
screen enclosed in quotes. This is because the original parameter @c contained
a space once expanded. CMDTIME attempts to keep the same number of parameters
by enclosing them in quotes. In hindsight, this may not be the best method
because it takes away some of the user's control. For this reason, I've added
two more substitution options for single- and double-quotes. The new version
is available at
http://www.rsds.ca/misc.html.
RB> type nul > $.$
RB>
RB> cmdtimew ren $.$ @X.htm
RB>
RB> dir
RB>
RB> 2003-0~1 HTM 0 04-17-03 4:04p 2003-04-17.htm
RB>
RB> which is OK, but I was after time as well.
RB>
RB> Have I missed something?
Sort of... The problem is a DOS / Windows limitation that doesn't allow you to
include certain characters (in this case a colon) in a file name. Using the
_new_ version of the program, you could enter something like:
cmdtimew ren spar001.htm @Q@X_@H.@
[email protected]@Q
which should take your file and rename it to include both the date and time
information. Does this help?
Bob
-+- blueMail/Linux 1.0
--- BBBS/LiI v4.01 Flag-4
* Origin: The Power Station BBS * powerstationbbs.ca * (1:342/5)