Path: csiph.com!aioe.org!.POSTED!not-for-mail From: Francky Leyn Newsgroups: alt.comp.lang.shell.batch.msdos Subject: Re: counting in DOS Date: Fri, 10 Jul 2015 18:41:23 +0200 Organization: private Lines: 57 Message-ID: <559FF5B3.80103@Leyn.eu> References: Reply-To: Francky@Leyn.eu NNTP-Posting-Host: UyFrc88eHG5Hq+S5mb7hAw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: aioe.org alt.comp.lang.shell.batch.msdos:12 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 > >