Increment numeric part of string

J

JohnNews

Folks:


I have a bunch of Windows Media Player files which I can launch from the
Command Prompt with a (DOS) command like:
[ WMplayer
"http://Johnen.lines.com/mcasx.asx?media=2764375&system=4536760" ]


How do I use DOS commands like: FIND(STR), FOR .. IN .. DO, etc to achieve
the following:


* I need to INCREMENT the numeric part of the above string (2764375) by 1
before launching [ WMplayer "
http://Johnen.lines.com/mcasx.asx?media=2764375&system=4536760" ] again.
* How can I achieve the above goal


Thanks,
John.
 
J

Jerold Schulman

Folks:


I have a bunch of Windows Media Player files which I can launch from the
Command Prompt with a (DOS) command like:
[ WMplayer
"http://Johnen.lines.com/mcasx.asx?media=2764375&system=4536760" ]


How do I use DOS commands like: FIND(STR), FOR .. IN .. DO, etc to achieve
the following:


* I need to INCREMENT the numeric part of the above string (2764375) by 1
before launching [ WMplayer "
http://Johnen.lines.com/mcasx.asx?media=2764375&system=4536760" ] again.
* How can I achieve the above goal


@echo off
setlocal
set var=WMplayer "http://Johnen.lines.com/mcasx.asx?media=2764375&system=4536760"
for /f "Tokens=1,2* Delims==&" %%a in ('@echo %var%') do (
set p1=%%a=
set p2=%%b
set p3=%%c
call :doit
)
endlocal&%wmp%
goto :EOF
:doit
:: Assuming the number never starts with 0
set /a p2=%p2% + 1
set wmp=%p1%%p2%&%p3%

Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
G

guard

I have a bunch of Windows Media Player files which I can launch from the
Command Prompt with a (DOS) command like:
[ WMplayer
"http://Johnen.lines.com/mcasx.asx?media=2764375&system=4536760" ]


How do I use DOS commands like: FIND(STR), FOR .. IN .. DO, etc to achieve
the following:


* I need to INCREMENT the numeric part of the above string (2764375) by 1
before launching [ WMplayer "
http://Johnen.lines.com/mcasx.asx?media=2764375&system=4536760" ] again.
* How can I achieve the above goal
For Windows NT/2K/XP/K3, you only need the FOR command.
At a command prompt (watch for line wrap):

*******

FOR /L %A IN (2764375,1,HighestNumber) DO @(WMplayer
"http://Johnen.lines.com/mcasx.asx?media=%A&system=4536760")

*******
See the "FOR Page" for more info.
(http://TheSystemGuard.com/TheGuardBook/CCS-Int/FOR.htm)


-tsg

/-----------------+---------------+----------------------\
| COMPATIBILITY | CLARITY | SPEED |
| Write code ONCE | Make it clear | THEN...Make it fast! |
\-----------------+---------------+----------------------/
400+ command-line resources using ONLY native NT commands!
(http://TheSystemGuard.com/default.asp#MasterCommandList)
 
J

JohnNews

Guard:


Thanks for your input. It worked well; both at the command prompt (%) and
in a batch file (%%). Now for an extension

As the variable is incremented, the appropriate Windows Media Player (WMP)
file is launched.
If the WMP file is not available then a popup window appears and I can
manually cancel same to allow incrementation to continue freely.

** How can I programmatically (from within the batch file) click on the
OK button of the popup window so that the incrementation process can
continue ?

** I do not always want to launch the WMP file, even if that WMP file
does exist. Rather than LAUNCH each available/existing WMP file, how can I
merely just check to see if the WMP file EXISTS (and can therefore be
readily launched if I so desire). What would be the syntax of the DOS
command to accomplish this second goal ?




Thanks, in advance, again,
John.









guard said:
I have a bunch of Windows Media Player files which I can launch from the
Command Prompt with a (DOS) command like:
[ WMplayer
"http://Johnen.lines.com/mcasx.asx?media=2764375&system=4536760" ]


How do I use DOS commands like: FIND(STR), FOR .. IN .. DO, etc to achieve
the following:


* I need to INCREMENT the numeric part of the above string (2764375)
by
1
before launching [ WMplayer "
http://Johnen.lines.com/mcasx.asx?media=2764375&system=4536760" ] again.
* How can I achieve the above goal
For Windows NT/2K/XP/K3, you only need the FOR command.
At a command prompt (watch for line wrap):

*******

FOR /L %A IN (2764375,1,HighestNumber) DO @(WMplayer
"http://Johnen.lines.com/mcasx.asx?media=%A&system=4536760")

*******
See the "FOR Page" for more info.
(http://TheSystemGuard.com/TheGuardBook/CCS-Int/FOR.htm)


-tsg

/-----------------+---------------+----------------------\
| COMPATIBILITY | CLARITY | SPEED |
| Write code ONCE | Make it clear | THEN...Make it fast! |
\-----------------+---------------+----------------------/
400+ command-line resources using ONLY native NT commands!
(http://TheSystemGuard.com/default.asp#MasterCommandList)
 
M

Marty List

JohnNews said:
Guard:


Thanks for your input. It worked well; both at the command prompt (%) and
in a batch file (%%). Now for an extension

As the variable is incremented, the appropriate Windows Media Player (WMP)
file is launched.
If the WMP file is not available then a popup window appears and I can
manually cancel same to allow incrementation to continue freely.

** How can I programmatically (from within the batch file) click on the
OK button of the popup window so that the incrementation process can
continue ?

** I do not always want to launch the WMP file, even if that WMP file
does exist. Rather than LAUNCH each available/existing WMP file, how can I
merely just check to see if the WMP file EXISTS (and can therefore be
readily launched if I so desire). What would be the syntax of the DOS
command to accomplish this second goal ?




Thanks, in advance, again,
John.

You could try the freeware tool WGET.EXE:
http://www.gnu.org/software/wget/wget.html


This is from the help file:

--spider

When invoked with this option, Wget will behave as a Web "spider", which
means that it will not download the pages, just check that they are there.
For example, you can use Wget to check your bookmarks:

wget.exe --spider --force-html -i bookmarks.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top