Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

syntax %date:~6,4% and %time:~6,2%

995 views
Skip to first unread message

Wilfrid

unread,
Sep 15, 2008, 10:59:17 AM9/15/08
to
Hi,
I am trying to understand the use of %date:~6,4% and %time:~6,2% in a ren
command.
What is the meaning of ~6,4, I beleive these are position on a certain
amount of character (?) but without certainty.
I am on XP with regional settings in UK.
Thanks in advance for your help


Matthias Tacke

unread,
Sep 15, 2008, 11:21:43 AM9/15/08
to
You are right, he numbers are offset and length,
for details see
set /?
or
<http://www.ss64.com/nt/syntax-substring.html>

HTH
Matthias

Timo Salmi

unread,
Sep 15, 2008, 1:06:36 PM9/15/08
to

Dr J R Stockton

unread,
Sep 15, 2008, 2:20:52 PM9/15/08
to
In alt.msdos.batch message <48ce7845$0$10806$426a...@news.free.fr>,
Mon, 15 Sep 2008 16:59:17, Wilfrid <gril...@yahoo.com> posted:
>I am trying to understand the use of and %time:~6,2% in a ren

>command.
>What is the meaning of ~6,4, I beleive these are position on a certain
>amount of character (?) but without certainty.
>I am on XP with regional settings in UK.

The purpose is to take the date and time strings in the format that the
author expected and to return only some specific part of them, selected
by position, e.g. it omits the first six characters of the date and
returns the next four. It is probably intended to return the four-digit
year and the time in seconds (or maybe am/pm).

But be careful. Default US settings can be expected to give, for
%date%, mm/dd/yyyy and UK settings to give dd/mm/yyyy. But, while the
initial country setting sets a date format setting, that setting can
easily be changed in Control Panel. Mine is set to yyyy-mm-dd; so,
today, rather than getting 2008, I get 9-15.

The technique should only be used if you can be sure that all relevant
systems are and will remain set to the expected date (and time) format.
Otherwise, in on-topic systems (yours is off-topic, and you should have
used a.m.b.NT; see weekly "Batch file information and FAQs") you can use
NOWMINUS, via sig line 3; and in systems with WSH you can also use
JavaScript or VBScript to get the information unambiguously.

--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05.
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.

mik3...@gmail.com

unread,
Sep 15, 2008, 10:57:52 PM9/15/08
to

you can use vbscript to get date information, regardless of regional
settings on your computer.

theDate=Now
theYear=Year(theDate)
theMonth=Month(theDate)
WScript.Echo theYear,theMonth

0 new messages