FOR /F works on WIN 10 and not on XP

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
miskox
Posts: 553
Joined: 28 Jun 2010 03:46

FOR /F works on WIN 10 and not on XP

#1 Post by miskox » 08 Nov 2022 11:01

Hello all!

This code

Code: Select all

@echo off
set var=0001
for /f "tokens=* delims=0" %%~ in ("%var%") do set var=%%~
echo %var%x
Result on Windows 10:

Code: Select all

1x
Result on XP:

Code: Select all

x
works on Windows 10 but not on XP. Any ideas why?

It removes leading zeroes.

Thanks.
Saso

(This approach is here: viewtopic.php?f=3&t=8136)

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

Re: FOR /F works on WIN 10 and not on XP

#2 Post by aGerman » 08 Nov 2022 14:08

Usually the ~ introduces modifiers in FOR variables. Do you see the same behavior with a letter as variable name?

Steffen

miskox
Posts: 553
Joined: 28 Jun 2010 03:46

Re: FOR /F works on WIN 10 and not on XP

#3 Post by miskox » 08 Nov 2022 14:16

You were right - though I think I tried that and I think it didn't work. I replaced '~' with a letter and it works.

Thanks.
Saso

Post Reply