home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.msdos.batch.nt      Fun with Windows NT batch files      68,980 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 67,430 of 68,980   
   dr.j.r.stockton@gmail.com to All   
   Batch : XCOPY ERRORLEVEL grammar? advice   
   19 Jun 19 08:55:37   
   
   I have the following script in a batch file.  The loop works as hoped for, if   
   the file or folder %from%%%J\%%K exists; %%K may contain wildcards.  Within   
   the loop, ignore the 'rem' and 'echo' lines; they do no harm.   
      
   If the file/folder %from%%%J\%%K does not exist, then I have not done   
   everything correctly _before_ calling the batch file.  As is, XCOPY says "File   
   not found - %%K" or similar.  But if there are many later files/folders which   
   do exist and pass the '/D'    
   test, that error message will rapidly vanish upwards, and I will not see it.   
      
   If the file/folder was not found, I do not need to proceed; I want to fix my   
   previous error and restart.   
      
   So I want to detect the inability to XCOPY, echo a distinctive message   
   including %%J\%%K, and quit : label NOMORE is near enough to the end.  But the   
   REM line, if un-REMmed, breaks the loop.   
      
   A missing folder is unlikely, unless a name is mis-typed; so what happens then   
   is less important.   
      
   What should I put instead of the REMmed code, or ...?   
      
   8<---   
      
   FOR /F "eol=; tokens=1,2*" %%J IN (%Here%%Who4%LIST.TXT) DO (   
     XCOPY /D /F /Y /EXCLUDE:OMIT-SET.TXT %from%%%J\%%K  %unto%%%J\ %%L | find /v   
   " File(s) copied"   
      
   REM if ERRORLEVEL 1 echo  Failure with %%J\%%K  QUIT. & goto NOMORE   
      
   echo Considered %%J\%%K    
      
   rem Do similar for BLOK   
      
     )   
      
   8<---   
      
   --    
     (c) John Stockton, near London, UK.  Using Google Groups.           |   
    Mail: J.R.""""""""@physics.org - or as Reply-To, if any.             |   
      
   --- 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