FOR doesn't iterate properly
Posted: 05 Sep 2020 21:45
Hi folks. I have a simple script which is in a directory that contains the files DPI360.pdf, DPI361.pdf and DPI362.pdf:
I don't understand why it outputs thusly (pasted into Windows XP's CMD):
Code: Select all
FOR %G IN (*.pdf) DO (
SET newfile=%G
SET dpi=%newfile:~0,6%
echo %dpi%
)
I expectC:\printer>FOR %G IN (*.pdf) DO (
More? SET newfile=%G
More? SET dpi=%newfile:~0,6%
More? echo %dpi%
More? )
C:\printer>(
SET newfile=DPI360.pdf
SET dpi=DPI362
echo DPI362
)
DPI362
C:\printer>(
SET newfile=DPI361.pdf
SET dpi=DPI362
echo DPI362
)
DPI362
C:\printer>(
SET newfile=DPI362.pdf
SET dpi=DPI362
echo DPI362
)
DPI362
DPI360
DPI361
DPI362