PC Review


Reply
Thread Tools Rate Thread

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

 
 
rprgrmr
Guest
Posts: n/a
 
      15th Jan 2010
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
 
Reply With Quote
 
 
 
 
Pegasus [MVP]
Guest
Posts: n/a
 
      15th Jan 2010


"rprgrmr" <(E-Mail Removed)> said this in news item
news:7C30DE96-6C15-4D00-8B6E-(E-Mail Removed)...
> 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.

 
Reply With Quote
 
Tim Meddick
Guest
Posts: n/a
 
      16th Jan 2010
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" <(E-Mail Removed)> wrote in message
news:7C30DE96-6C15-4D00-8B6E-(E-Mail Removed)...
> 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


 
Reply With Quote
 
Al Dunbar
Guest
Posts: n/a
 
      17th Jan 2010
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" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:7C30DE96-6C15-4D00-8B6E-(E-Mail Removed)...
>> 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

>

 
Reply With Quote
 
Timo Salmi
Guest
Posts: n/a
 
 
Reply With Quote
 
Tim Meddick
Guest
Posts: n/a
 
      17th Jan 2010
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" <(E-Mail Removed)> wrote in message
news:6B4981CA-B348-4773-9A63-(E-Mail Removed)...
>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" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
>> Where are you looking for your "documentation"?
>>

>
> < clipped >
>

 
Reply With Quote
 
Al Dunbar
Guest
Posts: n/a
 
      18th Jan 2010
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:6B4981CA-B348-4773-9A63-(E-Mail Removed)...
>>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" <(E-Mail Removed)> wrote in message
>> news:#(E-Mail Removed)...
>>> Where are you looking for your "documentation"?
>>>

>>
>> < clipped >
>>

 
Reply With Quote
 
Petr Laznovsky
Guest
Posts: n/a
 
      18th Jan 2010

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.

rprgrmr wrote:
> 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

 
Reply With Quote
 
Pegasus [MVP]
Guest
Posts: n/a
 
      18th Jan 2010


"Petr Laznovsky" <(E-Mail Removed)> said this in news item
news:(E-Mail Removed)...
> 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.

 
Reply With Quote
 
foxidrive
Guest
Posts: n/a
 
      18th Jan 2010
On Mon, 18 Jan 2010 16:10:01 +0100, "Pegasus [MVP]" <(E-Mail Removed)>
wrote:
>"Petr Laznovsky" <(E-Mail Removed)> said this in news item
>news:(E-Mail Removed)...


>> 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.


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.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Microsoft Query - DETAILED documentation???? =?Utf-8?B?Sm9obnNsZw==?= Microsoft Excel Programming 3 22nd May 2007 03:36 PM
Where is the microsoft.web section used in web.config documented? clintonG Microsoft ASP .NET 4 24th Aug 2006 12:57 AM
I Need URL To Microsoft Documentation For Favorites clintonG Microsoft ASP .NET 4 4th Oct 2005 12:56 PM
I Need URL To Microsoft Documentation For Favorites clintonG Microsoft C# .NET 2 3rd Oct 2005 11:08 PM
I Need URL To Microsoft Documentation For Favorites clintonG Windows XP Internet Explorer 3 3rd Oct 2005 10:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:25 PM.