XP Bug with short names
Posted: 02 Dec 2011 14:32
Hi,
this question Batch parameter %~s1 gives incorrect 8.3 short name shows another XP-Bug.
As a result: XP copies too much characters while building the short name,
so you get for a path like
C:\temp\123456789ABCDEFGHIJKLMNOPQR\A[1].BAT
The short name
C:\temp\123456~1\A_1_~1.BATKLMNOPQR\a[1].bat
Instead of
C:\temp\123456~1\A_1_~1.BAT
And it seems to be only occurs, if the filename contains []+;,=<space>
It can be tested with this
jeb
this question Batch parameter %~s1 gives incorrect 8.3 short name shows another XP-Bug.
As a result: XP copies too much characters while building the short name,
so you get for a path like
C:\temp\123456789ABCDEFGHIJKLMNOPQR\A[1].BAT
The short name
C:\temp\123456~1\A_1_~1.BATKLMNOPQR\a[1].bat
Instead of
C:\temp\123456~1\A_1_~1.BAT
And it seems to be only occurs, if the filename contains []+;,=<space>

It can be tested with this
Code: Select all
@echo off
setlocal EnableDelayedExpansion
set myDir=
set myFile=a[1].bat
set map=123456789ABCDEFGHIJKLMNOPQRSTUVW
for /L %%n in (0 1 26) do (
set "myDir=!myDir!!map:~%%n,1!"
md !myDir!
echo dummy > "!myDir!\!myFile!"
echo Dir=!myDir!
for %%X in ("!myDir!\!myFile!") do echo %%~sX
echo(
del "!myDir!\!myFile!" > nul
rd !myDir!
)
jeb