Page 1 of 1

FOR /F works on WIN 10 and not on XP

Posted: 08 Nov 2022 11:01
by miskox
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)

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

Posted: 08 Nov 2022 14:08
by aGerman
Usually the ~ introduces modifiers in FOR variables. Do you see the same behavior with a letter as variable name?

Steffen

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

Posted: 08 Nov 2022 14:16
by miskox
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