Where is this (%date:~4%) documented in Microsoft documentation?

  • Thread starter Thread starter rprgrmr
  • Start date Start date
R

rprgrmr

Where is this string manipulation documented in Microsoft documentation? I
have looked at the SET command and the FOR command, and they suggest some of
this, but do not describe it fully.

examples:
%date:~4%

SET v_test=123abcd
Set v_replacement=xy
SET v_result=%v_test:ab=!v_replacement!%
ECHO %v_result%=123xycd
 
rprgrmr said:
Where is this string manipulation documented in Microsoft documentation? I
have looked at the SET command and the FOR command, and they suggest some
of
this, but do not describe it fully.

examples:
%date:~4%

SET v_test=123abcd
Set v_replacement=xy
SET v_result=%v_test:ab=!v_replacement!%
ECHO %v_result%=123xycd

Most of it is explained in "set /?". However, there are some weird and
wonderful tricks that people have found out over the years. Repost your
question in the newsgroup where the experts on batch files and the command
processor dwell: alt.msdos.batch.nt.
 
Where are you looking for your "documentation"?

It is a fact that typing " set /? " ...at the Command Prompt, actually gives a
more comprehensive explanation that looking under "SET" in the Windows XP "Help and
Support Center".

As far as I can see, the part headed "Environment variable substitution" is not
reproduced in "Help and Support Center" but is present in the command-line help
invoked by : [set /?]

==

Cheers, Tim Meddick, Peckham, London. :-)
 
I agree that, basically, the seeds of all you need to know are in the info
displayed by most commands when "/?" is given as the parameter. But that
documentation still leaves it up to the reader to figure out how to do the
less than obvious when it is not given as a specific example. Which is one
large reason why resources such as this newsgroup are valuable.

/Al

Tim Meddick said:
Where are you looking for your "documentation"?

It is a fact that typing " set /? " ...at the Command Prompt,
actually gives a more comprehensive explanation that looking under "SET"
in the Windows XP "Help and Support Center".

As far as I can see, the part headed "Environment variable substitution"
is not reproduced in "Help and Support Center" but is present in the
command-line help invoked by : [set /?]

==

Cheers, Tim Meddick, Peckham, London. :-)




rprgrmr said:
Where is this string manipulation documented in Microsoft documentation?
I
have looked at the SET command and the FOR command, and they suggest some
of
this, but do not describe it fully.

examples:
%date:~4%

SET v_test=123abcd
Set v_replacement=xy
SET v_result=%v_test:ab=!v_replacement!%
ECHO %v_result%=123xycd
 
Al,
While I know groups such as this are "valuable" for the same reasons as you...

All I was asking and pointing out to the OP was "where did he get his documentation?"
and (because) the documentation provided by "Window's Help and Support Center" *is*
incomplete.

Whereas, the information (in this case only) provided by [ set /? ] *does* include
exactly the information the OP was looking for (as far as I can make out), plus
examples *are* included as well (again, in the case of the SET command only).

[This is why I was asking "where did he get his documentation?"]

==

Cheers, Tim Meddick, Peckham, London. :-)
 
Tom,

Being somewhat broader and more general, my comments were only incidental to
the thread, and not intended to indicate disagreement with anything you said
(or asked).

/Al

Tim Meddick said:
Al,
While I know groups such as this are "valuable" for the same reasons
as you...

All I was asking and pointing out to the OP was "where did he get his
documentation?" and (because) the documentation provided by "Window's Help
and Support Center" *is* incomplete.

Whereas, the information (in this case only) provided by [ set /? ]
*does* include exactly the information the OP was looking for (as far as I
can make out), plus examples *are* included as well (again, in the case of
the SET command only).

[This is why I was asking "where did he get his documentation?"]

==

Cheers, Tim Meddick, Peckham, London. :-)



Al Dunbar said:
I agree that, basically, the seeds of all you need to know are in the info
displayed by most commands when "/?" is given as the parameter. But that
documentation still leaves it up to the reader to figure out how to do the
less than obvious when it is not given as a specific example. Which is one
large reason why resources such as this newsgroup are valuable.

/Al



< clipped >
 
I am agree with rprgrmr,

I am beginner in the batch scripts, but i deeply feel insufficient
documentation. I try to read the script examples from the internet and
understand, but sometimes this is VERY hard. For example I want to know
what the dot character "." does in the batch. Some people use it in with
echo command, some people use it in the middle of batch. I spend meny
hours of googling but have no luck. Same situation with "FOR /F" because
google ignore the "/" and similar characters :-(

L.
 
Petr Laznovsky said:
I am agree with rprgrmr,

I am beginner in the batch scripts, but i deeply feel insufficient
documentation. I try to read the script examples from the internet and
understand, but sometimes this is VERY hard. For example I want to know
what the dot character "." does in the batch. Some people use it in with
echo command, some people use it in the middle of batch. I spend meny
hours of googling but have no luck. Same situation with "FOR /F" because
google ignore the "/" and similar characters :-(

L.

You were unable to find anything on the "dot" because it is just a filler
that gives the batch file something to chew. The following lines illustrate
the concept - they all do exactly the same:

if %name%.==Peter.
if "%name%"=="Peter"
if [%name%]==[Peter]

Why do you need these "fillers"? Simple: Because if the %name% variable is a
blank then you would get a syntax error:

This is invalid: if ==Peter
This is valid: if .==Peter.

About for /F: Once more you should open a Command Prompt and type
for /?

There is a large amount of helpt there, including on the /F switch.
 
"Petr Laznovsky" <[email protected]> said this in news item

In addition to Pegasus' comments:

*) In the case below it stops echo from generating an error message if a
variable is empty.

This will generate an error if %file% is empty/blank.
echo %file%

but this will echo a blank line
echo.%file%

and in another case: this will echo the word On
echo.On

whereas this line will be interpreted as the keyword ECHO ON
echo On


In all the cases above the dot can be replaced with many characters such as
/ and \ and others.

In the past someone tested a whole slew of them and I think the / character
was found to be the most compatible, but none of them are trouble free in
all cases.

*) Another use for a period is as a representation of the current directory

This line will execute notepad ONLY if the executeable is in the current
directory. Linux uses this syntax extensively.
..\notepad.exe

*) You may see two periods in a cd command such as
CD ..

and in that case it represents the parent folder and it will change the
directory to the folder that is next higher up in the directory tree.
EG: if you are in c:\windows\system32 then it will leave you in c:\windows


*) Yet another use for a period is as a wildcard in a regular expression
such as you might find with findstr.exe

In these three commands the . means "any character" so it will match moat
and gone but will not match dune because the second character is not an "o"

echo moat|findstr /r ".o.."
echo gone|findstr /r ".o.."
echo dune|findstr /r ".o.."



Hope that helps. Feel free to pose any other questions you have.
 
I am agree with rprgrmr,

I am beginner in the batch scripts, but i deeply feel insufficient
documentation. I try to read the script examples from the internet and
understand, but sometimes this is VERY hard. For example I want to know
what the dot character "." does in the batch. Some people use it in with
echo command, some people use it in the middle of batch. I spend meny
hours of googling but have no luck. Same situation with "FOR /F" because
google ignore the "/" and similar characters :-(

L.
 
Petr,
if you have an *exact* [string] match you want to search google for - enclose
it inside double quotation marks, thus :

"FOR /F"

....and then hit the search button!!

This works for unusual characters that would normally be ignored, and for groups of
words where you want a match to the exact same sequence of words - just enclose in
"quotes".



P.S. I find that if typing [command /?] at the "Command Prompt" is insufficient,
then looking the command up in the Window's "Help and Support Center" generally has
more detail and examples (though, not always).

Start the Help and Support Center and type in : "Command-line A-Z" into the search
box and double-click on the "Command-line reference A-Z" item in the results pane.

Then, in the Command-line reference A-Z, click on the letter that the command you
want info on starts with, and you are taken to all commands that begin with that
letter...


==

Cheers, Tim Meddick, Peckham, London. :-)
 
Tim Meddick said:
Petr,
if you have an *exact* [string] match you want to search google
for - enclose it inside double quotation marks, thus :

"FOR /F"

...and then hit the search button!!

This works for unusual characters that would normally be ignored, and for
groups of words where you want a match to the exact same sequence of
words - just enclose in "quotes".



P.S. I find that if typing [command /?] at the "Command Prompt" is
insufficient, then looking the command up in the Window's "Help and
Support Center" generally has more detail and examples (though, not
always).

Seeing that most machines these days run in a 32 or 64-bit environment, "cmd
/?" might be a more appropriate command to run than "command /?". AFAIR,
command.com does not even support the syntax "for /F".
 
Hmm.

Consider the line

ECHO.txt

Now - should/does this

a) echo "txt" to the console
or
b) Invoke NOTEPAD (or whatever) on a file called "echo.txt" ??

Answer : it does a) As for what it should do - I'll polish up my halo and
not tread there...

That's another "Gotcha" for batch files. if the file echo.txt exists then
it will start up Notepad or whatever.
Personally, I use ECHO\ (when I remember) because "." gets lost in the
specks on my specs.

From memory, none of the echo delimiters were without problems but echo\ is
more visible than echo.
 
Tim Meddick said:
P.S. I find that if typing [command /?] at the "Command Prompt" is
insufficient, then looking the command up in the Window's "Help and
Support Center" generally has more detail and examples (though, not
always).

Seeing that most machines these days run in a 32 or 64-bit environment,
"cmd /?" might be a more appropriate command to run than "command /?".
AFAIR, command.com does not even support the syntax "for /F".

I'm pretty sure Tim meant "command" as a stand-in for the command you
want to run; i.e., "commandYouWantToRun /?"
 
David Trimboli said:
Tim Meddick said:
P.S. I find that if typing [command /?] at the "Command Prompt" is
insufficient, then looking the command up in the Window's "Help and
Support Center" generally has more detail and examples (though, not
always).

Seeing that most machines these days run in a 32 or 64-bit environment,
"cmd /?" might be a more appropriate command to run than "command /?".
AFAIR, command.com does not even support the syntax "for /F".

I'm pretty sure Tim meant "command" as a stand-in for the command you want
to run; i.e., "commandYouWantToRun /?"

Yes, there is a nice ambiguity there. On the other hand there is at least
one very prominent and very knowledgeable respondent in this newsgroup who
swears by Windows 98 . . .
 
Tim said:
Petr,
if you have an *exact* [string] match you want to search google
for - enclose it inside double quotation marks, thus :

"FOR /F"

...and then hit the search button!!

This works for unusual characters that would normally be ignored, and
for groups of words where you want a match to the exact same sequence of
words - just enclose in "quotes".

Unfortunatelly this does not help. I am tried it many times. When I try
to search _for /f_ than I got 624 000 000 pages, when I try to search
_"for/f"_ than I got 6 200 000 which is smaller number, but still too
big to get ONLY pages realted to batch programming. Try it, only the
first four pages are batch related, following unrelated crap...

check this:

-----------------------------------------------------------------------
Q: Google ignores some punctuation and special characters, including ! ?
, . ; [ ] @ / # < > .

A: Because punctuation is typically not as important as the text around
it, Google ignores most punctuation in your search terms.
 
Yes, indeed, I did mean "command /?" as in : "the_command_you_want_to_run /?"

But then I have only been answering questions (in some selected M$ NGroups) for a
year, so I am still learning about *what* is sometimes taken as ambiguity.

I also *like* W98, but feel that XP is, by far, the better OS, in preference to Vista
and [probably] to W7 too!

The PC and it's OS will have to advance as far again, as XP is to W98, before I
invest in an upgrade.

I think people upgrade at the drop of a hat, unnecessarily.

Did you know that they still use 8086 computers in the Space Shuttle (Albeit, 7 of
them)?

If it [your PC] is still good for the job you wanted it for - why change?!!...

==

Cheers, Tim Meddick, Peckham, London. :-)
 
billious said:
Whereas the rest of us swear AT W98.

I'm getting there. The crashing/freezing that once was never seen on my 98
system has progressed to an almost daily nuisance as of late. It's always
related to using IE. I have Netscape but never did like it. OTOH, I had two
HDDs die on me (WD click of death), replaced the entire computer for faster
CPU and more memory, etc. without ever reinstalling Windows 98. Perhaps it
might be time to for me to see how a fresh install on a different brand of
HD goes.

On a side note, I have been playing with Ubuntu lately but I'm not leaving
98 just yet. I just multi-boot to whatever OS is required for a particular
task.
 
I typed into the Google search page, the following :


"FOR command" microsoft


.....and hit "Google Search". The FIRST link at the top was this :

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/for.mspx

If you need more information than this page provides on the FOR command, then I would
try posting your exact query here!!...

==

Cheers, Tim Meddick, Peckham, London. :-)




Petr Laznovsky said:
Tim said:
Petr,
if you have an *exact* [string] match you want to search google for -
enclose it inside double quotation marks, thus :

"FOR /F"

...and then hit the search button!!

This works for unusual characters that would normally be ignored, and for groups
of words where you want a match to the exact same sequence of words - just enclose
in "quotes".

Unfortunatelly this does not help. I am tried it many times. When I try to search
_for /f_ than I got 624 000 000 pages, when I try to search _"for/f"_ than I got 6
200 000 which is smaller number, but still too big to get ONLY pages realted to
batch programming. Try it, only the first four pages are batch related, following
unrelated crap...

check this:

-----------------------------------------------------------------------
Q: Google ignores some punctuation and special characters, including ! ? , . ; [ ]
@ / # < > .

A: Because punctuation is typically not as important as the text around it, Google
ignores most punctuation in your search terms.
 
Back
Top