Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > alt.comp.lang.shell.batch.msdos > #9

Re: counting in DOS

From Todd Vargo <tlvargo@sbcglobal.netz>
Newsgroups alt.comp.lang.shell.batch.msdos
Subject Re: counting in DOS
Date 2015-07-03 02:52 -0400
Organization albasani.net
Message-ID <mn5bep$l02$1@news.albasani.net> (permalink)
References <mn54vs$ok0$1@speranza.aioe.org>

Show all headers | View raw


On 7/3/2015 1:01 AM, Francky Leyn wrote:
> Hello,
>
> I have a script crop_odd.bat which contains:
> i_view32 %1.jpg /crop=(0,0,1634,2160,0) /convert=%1.jpg
> If one types:
> crop_odd 113
> then this is expanded to:
> i_view32 113.jpg /crop=(0,0,1634,2160,0) /convert=113.jpg
>
> Now I want to extend this script with:
>
> 1) If I type
>     crop_odd 113
>     I want this seen expanded to:
>     i_view32 113.jpg /crop=(0,0,1634,2160,0) /convert="p. 113.jpg"
>     How must the script be expanded, so that this is the result?
>
> 2) If the script crop_even is:
>     i_view32 %1.jpg /crop=(0,0,1634,2160,0) /convert=%1.jpg
>     then typing
>     crop_even 113
>     will be expanded into
>     i_view32 113.jpg /crop=(0,0,1634,2160,0) /convert=113.jpg
>     Instead of this, I want it expanded into:
>     i_view32 113.jpg /crop=(0,0,1634,2160,0) /convert="p. 114.jpg"
>
>     In order to obtain this 2 thing must be present:
>     a) proper quoting like in 1).
>     b) one must be able to count: 113 -> 114
>
>     This is not all. Consider the following:
>     crop_even 003
>     This should be expanded to
>     i_view32 003.jpg /crop=(0,0,1634,2160,0) /convert="p. 004.jpg"
>
>     The same for:
>     crop_even 013
>     which must be expanded into:
>     i_view32 013.jpg /crop=(0,0,1634,2160,0) /convert="p. 014.jpg"
>
> How to realize all the above?
>
> Best regards,
>
> Francky Leyn

The name of your batch files are a bit deceiving, but from your 
description above, the following code seems to be your goal. Personally, 
I would have named them crop_same.bat and crop_incr.bat but that's just me.


Change crop_odd.bat to this,
i_view32 %1.jpg /crop=(0,0,1634,2160,0) /convert="p. %1.jpg"


Change crop_even.bat to this,
@echo off
set "n=1%1"
set /a n+=1
set "n=%n:~1%"
i_view32 %1.jpg /crop=(0,0,1634,2160,0) /convert="p. %n%.jpg"


Give these two a try and post back to let us know if it does what you 
wanted.

-- 
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

Back to alt.comp.lang.shell.batch.msdos | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

counting in DOS Francky Leyn <Francky@Leyn.eu> - 2015-07-03 07:01 +0200
  Re: counting in DOS Todd Vargo <tlvargo@sbcglobal.netz> - 2015-07-03 02:52 -0400
    Re: counting in DOS Todd Vargo <tlvargo@sbcglobal.netz> - 2015-07-09 17:40 -0400
      Re: counting in DOS Francky Leyn <Francky@Leyn.eu> - 2015-07-10 18:41 +0200
        Re: counting in DOS Todd Vargo <tlvargo@sbcglobal.netz> - 2015-07-10 12:59 -0400

csiph-web