[Solved] Is this doable?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
renzlo
Posts: 116
Joined: 03 May 2011 19:06

[Solved] Is this doable?

#1 Post by renzlo » 07 Jun 2011 17:33

Hi Guys,

I was wondering if it's possible to code this situation:

I want to echo this: <Pages>constantnumber_EquipmentLog001.TIF</Pages>

But the scenario is that, that code should be echoed based on the "page range" inputted by the user, for example:

after executing the batch:

Code: Select all

from page: 45 (inputted by the user)
to page: 45 (inputted by the user)

Result: <Pages>constantnumber_EquipmentLog045.TIF</Pages>

or

from page: 45 (inputted by the user)
to page: 46 (inputted by the user)

Result: <Pages>constantnumber_EquipmentLog045 constantnumber_EquipmentLog046.TIF</Pages>

or

from page: 45 (inputted by the user)
to page: 47 (inputted by the user)

Result: <Pages>constantnumber_EquipmentLog045 constantnumber_EquipmentLog046 constantnumber_EquipmentLog047.TIF</Pages>

or

from page: 45 (inputted by the user)
to page: 50 (inputted by the user)

Result: <Pages>constantnumber_EquipmentLog045 constantnumber_EquipmentLog046 constantnumber_EquipmentLog047 constantnumber_EquipmentLog048 constantnumber_EquipmentLog049 constantnumber_EquipmentLog050.TIF</Pages>



Is this possible to code in batch?

Thanks in advance.


-renzlo[b][/b]
Last edited by renzlo on 09 Jun 2011 00:38, edited 2 times in total.

Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

Re: Is this doable?

#2 Post by Cleptography » 07 Jun 2011 17:52

If you are just looking to echo that line you would

Code: Select all

echo\^<Pages^>constantnumber_EquipmentLog001.TIF^</Pages^>

renzlo
Posts: 116
Joined: 03 May 2011 19:06

Re: Is this doable?

#3 Post by renzlo » 07 Jun 2011 18:03

clep it is not just echoing the line, you have meet the conditions on page range.

Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

Re: Is this doable?

#4 Post by Cleptography » 07 Jun 2011 18:25

Sorry missed that part :oops:
It would take me a min to figure it out as I am not a batch pro.
Truthfully I don't want to at this min.
One of the other experts will be around shortly to help you.

renzlo
Posts: 116
Joined: 03 May 2011 19:06

Re: Is this doable?

#5 Post by renzlo » 07 Jun 2011 18:38

Yes,i hope that is doable.

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Is this doable?

#6 Post by aGerman » 07 Jun 2011 18:45

Of course.

Code: Select all

@echo off &setlocal enabledelayedexpansion
set "bTag=<Pages>"
set "eTag=</Pages>"
set "strPart1=constantnumber_EquipmentLog"
set "strPart2=.TIF "
set /p "from=from page: "
set /p "to=to page: "
set /a from+=1000, to+=1000
for /l %%i in (%from%,1,%to%) do (
  set /a x=%%i
  set "innerML=!innerML!%strPart1%!x:~1!%strPart2%"
)
echo(!bTag!!innerML:~,-1!!eTag!
pause

Regards
aGerman

renzlo
Posts: 116
Joined: 03 May 2011 19:06

Re: Is this doable?

#7 Post by renzlo » 07 Jun 2011 18:59

Perfect aGerman. Thank you always.

Post Reply