How to catch empty value (TOO) in FOR loop?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
budhax
Posts: 63
Joined: 09 Oct 2006 12:25

How to catch empty value (TOO) in FOR loop?

#1 Post by budhax » 30 Aug 2008 08:23

Hello,

From this file: in.sh droped on my script below, (indentation are tabs characters)

Code: Select all

#Comment
U1
   V11
      W111
      W112


I would get this output (and catch empty values too):
[U1] [] []
[] [V11] []
[] [] [W111]
[] [] [W112]


My script jump over empty value, and outputs this:

Code: Select all

[U1] [] []
[ "V11] [] []
[ "" "W111] [] []
[ "" "W112] [] []


How to catch empty values too? Thanks

Code: Select all

@ECHO OFF
@SETLOCAL ENABLEDELAYEDEXPANSION
CD /D "%~DP1"
IF "%~1"==""            (SET ErrU=1&GOTO:FinE)
IF /i NOT "%~x1"==".SH" (SET ErrE=1&GOTO:FinE)

ECHO.---------------------------
ECHO.Calcule en cours.
ECHO.Patientez ...
ECHO.

SET FNi=%~nx1
SET FNo=%~n1_.SH
FOR /f "SKIP=1 Delims=" %%f in ('TYPE "%FNi%"') DO (
   SET Li=%%f
   SET Li=!Li:   =" "!
   ::ECHO.[!Li!]
   FOR /f "Tokens=1-3 Delims=" %%u in ("!Li!") DO (ECHO.[%%~u] [%%~v] [%%~w])
)
GOTO:FinN


:FinE
COLOR 0C
IF DEFINED ErrF (ECHO.***  ERREUR: Fichier Absent!)
IF DEFINED ErrE (ECHO.***  ERREUR: De L'Extention!)
IF DEFINED ErrU (ECHO.***  USAGE : DRAG and DROP.!)
:FinN
ENDLOCAL&ECHO.&ECHO.Press To END ......&Pause>Nul&EXIT /b::_____________________

carlitos.dll
Posts: 11
Joined: 02 Jul 2008 07:42

#2 Post by carlitos.dll » 31 Aug 2008 20:38

The author has been removed this message.

Post Reply