Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > alt.comp.lang.shell.batch.msdos > #8 > unrolled thread
| Started by | Francky Leyn <Francky@Leyn.eu> |
|---|---|
| First post | 2015-07-03 07:01 +0200 |
| Last post | 2015-07-10 12:59 -0400 |
| Articles | 5 — 2 participants |
Back to article view | Back to alt.comp.lang.shell.batch.msdos
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
| From | Francky Leyn <Francky@Leyn.eu> |
|---|---|
| Date | 2015-07-03 07:01 +0200 |
| Subject | counting in DOS |
| Message-ID | <mn54vs$ok0$1@speranza.aioe.org> |
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
[toc] | [next] | [standalone]
| From | Todd Vargo <tlvargo@sbcglobal.netz> |
|---|---|
| Date | 2015-07-03 02:52 -0400 |
| Message-ID | <mn5bep$l02$1@news.albasani.net> |
| In reply to | #8 |
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)
[toc] | [prev] | [next] | [standalone]
| From | Todd Vargo <tlvargo@sbcglobal.netz> |
|---|---|
| Date | 2015-07-09 17:40 -0400 |
| Message-ID | <mnmpom$k52$1@news.albasani.net> |
| In reply to | #9 |
On 7/9/2015 10:54 AM, Francky Leyn wrote: > Hello Todd, > > The script is now called crop_double.bat : > > @echo off > set "n=1%1" Creates a variable named "n" and stores the value of %1, prefixed with a 1. This is done because some of your file numbers begin with a zero. So for 041, the value stored is 1041. > set /a n-=1 The /a switch indicates an mathematical operation, in this case it subtracts 1 from the value. Without the leading 1, it would provide incorrect results including removal of the leading zero(s). So the value stored becomes 1040. > set "n=%n:~1%" This removes the leading 1, so the value stored becomes 040. > mkdir "%CD%\02 crop" > i_view32 "%CD%\01 src\%1.jpg" /crop=(0,0,1634,2160,0) /convert="%CD%\02 > crop\p. %n%.jpg" > i_view32 "%CD%\01 src\%1.jpg" /crop=(1634,0,1634,2160,0) > /convert="%CD%\02 crop\p. %1.jpg" > > It does perfecly what I want. > > If have a jpg file 041.jpg in "01 src", > and if type at the prompt: > crop_double 041 > then 2 jpg files are generated: > "02 crop\p. 040.jpg" and > "02 crop\p. 041.jpg" > > However, I would like to understand the set commands. > Could you explain in detail what the different set commands do? > > Best regards, > > Francky -- Todd Vargo (Post questions to group only. Remove "z" to email personal messages)
[toc] | [prev] | [next] | [standalone]
| From | Francky Leyn <Francky@Leyn.eu> |
|---|---|
| Date | 2015-07-10 18:41 +0200 |
| Message-ID | <559FF5B3.80103@Leyn.eu> |
| In reply to | #11 |
On 7/9/2015 11:40 PM, Todd Vargo wrote: > On 7/9/2015 10:54 AM, Francky Leyn wrote: >> Hello Todd, >> >> The script is now called crop_double.bat : >> >> @echo off >> set "n=1%1" > > Creates a variable named "n" and stores the value of %1, prefixed with a > 1. This is done because some of your file numbers begin with a zero. > > So for 041, the value stored is 1041. > > >> set /a n-=1 > > The /a switch indicates an mathematical operation, in this case it > subtracts 1 from the value. Without the leading 1, it would provide > incorrect results including removal of the leading zero(s). > > So the value stored becomes 1040. > >> set "n=%n:~1%" > > This removes the leading 1, so the value stored becomes 040. Can go a bit more in detail? Why the 2 % signs? What means :~ ? >> mkdir "%CD%\02 crop" >> i_view32 "%CD%\01 src\%1.jpg" /crop=(0,0,1634,2160,0) /convert="%CD%\02 >> crop\p. %n%.jpg" >> i_view32 "%CD%\01 src\%1.jpg" /crop=(1634,0,1634,2160,0) >> /convert="%CD%\02 crop\p. %1.jpg" >> >> It does perfecly what I want. >> >> If have a jpg file 041.jpg in "01 src", >> and if type at the prompt: >> crop_double 041 >> then 2 jpg files are generated: >> "02 crop\p. 040.jpg" and >> "02 crop\p. 041.jpg" >> >> However, I would like to understand the set commands. >> Could you explain in detail what the different set commands do? >> >> Best regards, >> >> Francky > >
[toc] | [prev] | [next] | [standalone]
| From | Todd Vargo <tlvargo@sbcglobal.netz> |
|---|---|
| Date | 2015-07-10 12:59 -0400 |
| Message-ID | <mnotkn$eeq$1@news.albasani.net> |
| In reply to | #12 |
On 7/10/2015 12:41 PM, Francky Leyn wrote: > On 7/9/2015 11:40 PM, Todd Vargo wrote: >> On 7/9/2015 10:54 AM, Francky Leyn wrote: >>> Hello Todd, >>> >>> The script is now called crop_double.bat : >>> >>> @echo off >>> set "n=1%1" >> >> Creates a variable named "n" and stores the value of %1, prefixed with a >> 1. This is done because some of your file numbers begin with a zero. >> >> So for 041, the value stored is 1041. >> >> >>> set /a n-=1 >> >> The /a switch indicates an mathematical operation, in this case it >> subtracts 1 from the value. Without the leading 1, it would provide >> incorrect results including removal of the leading zero(s). >> >> So the value stored becomes 1040. >> >>> set "n=%n:~1%" >> >> This removes the leading 1, so the value stored becomes 040. > > > Can go a bit more in detail? > Why the 2 % signs? > What means :~ ? Type SET/? at command prompt for extensive help information. > > >>> mkdir "%CD%\02 crop" >>> i_view32 "%CD%\01 src\%1.jpg" /crop=(0,0,1634,2160,0) /convert="%CD%\02 >>> crop\p. %n%.jpg" >>> i_view32 "%CD%\01 src\%1.jpg" /crop=(1634,0,1634,2160,0) >>> /convert="%CD%\02 crop\p. %1.jpg" >>> >>> It does perfecly what I want. >>> >>> If have a jpg file 041.jpg in "01 src", >>> and if type at the prompt: >>> crop_double 041 >>> then 2 jpg files are generated: >>> "02 crop\p. 040.jpg" and >>> "02 crop\p. 041.jpg" >>> >>> However, I would like to understand the set commands. >>> Could you explain in detail what the different set commands do? >>> >>> Best regards, >>> >>> Francky >> >> > -- Todd Vargo (Post questions to group only. Remove "z" to email personal messages)
[toc] | [prev] | [standalone]
Back to top | Article view | alt.comp.lang.shell.batch.msdos
csiph-web