SCRIPTING - Windows batch-file errorlevel question
Translations
Englishالعربية
български
català
中文
čeština
dansk
Nederlands
eesti
suomi
français
Deutsch
Ελληνικά
עברית
हिंदी
magyar
Bahasa Indonesia
italiano
日本語
한국어
latviešu
lietuvių
norsk
polski
Português
română
русский
slovenčina
slovenski
español
svenska
ไทย
Türkçe
українська
Tiếng Việt
I've got a batch file that parses a bunch of file names out of a text file and concatenates them into a single strong - it was previously discussed here. However, I don't want the string to contain a file if the file throw an error when I run it through some command (like a VCS check, for example). Here's my attempt:
set FILE_LIST=
for /f %%x in (temp.txt) do (
:: perform a VCS test
accurev diff -b %%x
:: skip concatenation if error level is > 2
IF errorlevel 2 GOTO NEXT
:: perform the concatenation
set FILE_LIST=!FILE_LIST! %%x
:NEXT
:: print a message if here due to an error above
IF errorlevel 2 echo VCS problem with this file: %%x
)
The problem is - the script appears to stop executing the entire for-loop as soon as it finds one errorlevel greater than 2. If there are five files in the list and the third one has a VCS problem - the script only handles the first two.
This question and answers originated from www.stackoverflow.com
Question by dls (10/1/2009 9:35:21 PM)
Answer |
setlocal ENABLEDELAYEDEXPANSION
set FILE_LIST=
for /f %%x in (temp.txt) do (
accurev diff -b "%%~x"
IF errorlevel 2 (
echo VCS problem with this file: %%~x
) ELSE (
set FILE_LIST=!FILE_LIST! %%x
)
)
Answer by Anders
Find More Answers
Related Topics scripting batch-file errorlevel