Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch    |    Fun with MS-DOS batch files    |    42,547 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 40,774 of 42,547    |
|    Todd Vargo to foxidrive    |
|    Re: simple batch doesn't work    |
|    12 Oct 13 22:35:39    |
   
   From: tlvargo@sbcglobal.netz   
      
   On 10/12/2013 6:49 PM, foxidrive wrote:   
   > On 12/10/2013 23:55, jackkkk wrote:   
   >> Hi everyone I have a problem with this BAT:   
   >>   
   >>   
   >>   
   >>   
   >> SET cont=1   
   >>   
   >> FOR %%f IN ("*.jpg") DO (   
   >>   
   >> IF %cont==1(SET cont=2)   
   >>   
   >> ELSE( mogrify -rotate 90 "%%f"   
   >>   
   >> SET cont=1)   
   >>   
   >>   
   >>   
   >>   
   >>   
   >> )   
   >>   
   >>   
   >> The output says: ELSE V is not a command   
   >>   
   >   
   > The positioning of the parentheses and commands need to be on the same line,   
   with spaces: ) else (   
   >   
   > You will need delayed expansion to alter and use variables in a loop, too.   
   >   
   > The double quotes stop spaces from being an issue.   
   >   
   > SET "cont=1"   
   > FOR %%f IN (*.jpg) DO (   
   > IF "%cont%"=="1" (   
   > SET "cont=2"   
   > ) ELSE (   
   > mogrify -rotate 90 "%%f"   
   > SET "cont=1"   
   > )   
   > )   
   >   
      
   You did not replace % with ! for the variable to be used in the loop.   
   Also, my observation of what the code would do with expansion enabled   
   is, it would skip every other jpg file.   
      
   Since OP did not state the intended purpose for the batch, my question   
   to OP is, is that really what you intended the code to do?   
      
   --   
   Todd Vargo   
   (Post questions to group only. Remove "z" to email personal messages)   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca