I'm trying to write a batch file in Windows XP that takes in a fully-qualified path name and outputs the 8.3 short name version...
@echo off
echo "%~s1"
I have come across one particular case where this outputs an incorrect path and file...
C:\>test.bat "C:\Documents and Settings\angus\Local Settings\Temporary Internet Files\Content.IE5\2JSTM34V\62[1].ja2"
"C:\DOCUME~1\angus\LOCALS~1\TEMPOR~1\Content.IE5\2JSTM34V\62_1_~1.JA2M34V\62[1].ja2"
Note that the above output ("C:\DOCUME~1\angus\LOCALS~1\TEMPOR~1\Content.IE5\2JSTM34V\62_1_~1.JA2M34V\62[1].ja2") does not exist. If I remove the ".JA2M34V\62[1]" section from that output, however, then the resulting string would be a valid path to the original input file.
This seems to be a problem with the use of brackets ([]) in the filename. If I create a file 62.ja2 in the same directory, the output will be correct...
C:\>test.bat "C:\Documents and Settings\angus\Local Settings\Temporary Internet Files\Content.IE5\2JSTM34V\62.ja2"
"C:\DOCUME~1\angus\LOCALS~1\TEMPOR~1\Content.IE5\2JSTM34V\62.ja2"
Is this a bug in Windows? Does anybody know if there's a workaround to allow the batch file to properly handle this filename?