Can't remove <space> FOR delimiter

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
jeffgio
Posts: 1
Joined: 15 Dec 2011 09:59

Can't remove <space> FOR delimiter

#1 Post by jeffgio » 15 Dec 2011 10:05

I'm unable to ignore spaces in my FOR loop token parsing, Am I doing something wrong??

For /F "tokens=1-5 delims=," %%I IN (%_InputFile%) DO (
ECHO %%I
Call process_machine %%~I %%~J %%~K %%~L %%~M
)

The text file as lines like:
997_m1,/turfcare/997_M1_9M94,997_M1_9M94.xlsm,\\f05tc1\shared\V2Net\115778 - TC997T4 MY13MuleData Collection\,9M94 M1

aGerman
Expert
Posts: 4722
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Can't remove <space> FOR delimiter

#2 Post by aGerman » 15 Dec 2011 10:30

It's not a problem of your FOR loop but it's a problem of how you call your sub routine. You have to enclose arguments with spaces in quotation marks.

Code: Select all

@echo off &setlocal
set "_InputFile=test.txt"

For /F "tokens=1-5 delims=," %%I IN (%_InputFile%) DO (
  ECHO %%I
  Call :process_machine "%%~I" "%%~J" "%%~K" "%%~L" "%%~M"
)

pause
goto :eof

:process_machine
echo %~1
echo %~2
echo %~3
echo %~4
echo %~5
goto :eof

Regards
aGerman

Post Reply