for /F "delims=text" comment

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

for /F "delims=text" comment

#1 Post by foxidrive » 12 Jul 2013 13:40

Well, well well.

Hands up who knew that the delimiters in a for /F were case sensitive? I didn't.

Code: Select all

@echo off
for /f "delims=abc" %%a in ("ABCabc") do set "var=%%a"
echo "%var%"
pause


It returns:

"ABC"


It has been 10 or more years that I've been using delims and never have I struck an instance where the case was an issue - luck I guess.

Endoro
Posts: 244
Joined: 27 Mar 2013 01:29
Location: Bozen

Re: for /F "delims=text" comment

#2 Post by Endoro » 12 Jul 2013 15:01

I knew it. We had this recently at stackoverflow :wink:

Squashman
Expert
Posts: 4206
Joined: 23 Dec 2011 13:59

Re: for /F "delims=text" comment

#3 Post by Squashman » 12 Jul 2013 15:06

I kind of assumed it but never tested it because the token variables are case sensitive I would assume the delims are as well.

foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

Re: for /F "delims=text" comment

#4 Post by foxidrive » 12 Jul 2013 17:26

Endoro wrote:I knew it. We had this recently at stackoverflow :wink:


Yes indeed. I added my own bit too and didn't realise that Aacini's was spot on.

Squashman wrote:I kind of assumed it but never tested it because the token variables are case sensitive I would assume the delims are as well.


It's actually more useful being case sensitive. Can't get over it being something so obvious but I never struck it until today. :)
I was filtering out characters from a DATE command and tripped over it...

Post Reply