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,448 of 68,980    |
|    mokomoji to All    |
|    Re: Batch : XCOPY ERRORLEVEL grammar? ad    |
|    04 Aug 19 15:29:37    |
      From: mokomoji@naver.com              2019년 6월 20일 목요일 오전 12시 55분 38초 UTC+9, dr.       .r...@gmail.com 님의 말:       > 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. |              edit source 2              @echo off       setlocal       cd /d "%~dp0"       set "z_file=OMIT-SET.TXT"       set z_num1=0       set z_num2=       set z_num3=0       ::sample make souce       set "z_source=.\from\j"       set "z_target=.\unto\k"       rd /s /q "%z_source%"       rd /s /q "%z_target%"       md "%z_source%"       md "%z_target%"       set "herowho4=."       ::faile and true :: down line del       echo %z_source%;%z_target%;%z_file%>"%z_source%\%z_file%"       echo %z_source%;%z_target%;%z_file%>"%z_source%\1%z_file%"       echo %z_source%;%z_target%;%z_file%>"%z_source%\2%z_file%"       echo %z_source%;%z_target%;%z_file%>"%z_source%\4%z_file%"       echo %z_source%;%z_target%;%z_file%>"%z_source%\5%z_file%"              echo %z_source%;%z_target%;%z_file%>".\list.txt"       echo %z_source%;%z_target%;1%z_file%>>".\list.txt"       echo %z_source%;%z_target%;2%z_file%>>".\list.txt"       echo %z_source%;%z_target%;3%z_file%>>".\list.txt"       echo %z_source%;%z_target%;5%z_file%>>".\list.txt"              ::sample make souce end       FOR /F "tokens=1,2* delims=;" %%J IN (%herowho4%\LIST.TXT) DO (        xcopy /y "%%J\%%L" "%%K" 2>nul >nul||(       call set /a z_num2+=1       echo fallure with %%J\%%L FILE NOT FOUND NO COPY       )       call set /a z_num1+=1       echo copy from:%%J to:%%K file:%%L copy       )              set /a z_num3=%z_num2%+%z_num1%       echo total file %z_num3%       echo %z_num1% file(s) copy       if defined z_num2 echo %z_num2% file(s) not found              goto :end              :end       endlocal       pause              --- 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