I am trying to convert a long file name to a short file name (8.3) on Windows.
The batch file with the command line argument works as intended:
short.bat:
@echo OFF echo %~s1
calling short.bat C:\Documents and Settings\User\NTUSER.DAT returns C:\DOCUM~1\USER\NTUSER.DAT
However, I do not like to have an extra .bat file for this. I would prefer to call cmd.exe whole command from ruby ββscript. How can i do this?
As an intermediate step, I tried hard-coded the path in the batch file, but this does not work:
short1.bat:
@echo OFF SET filename="C:\Documents and Settings\User\NTUSER.DAT" echo %filename% echo %~sfilename%
echo %filename% works, but echo %~sfilename% gives the following error:
The following usage of the path operator in batch-parameter substitution is invalid: %~sfilename% For valid formats type CALL /? or FOR /?
If short1.bat works, how can I convert it to a single line, which can be called using cmd.exe \c ... ?
Another question arises ( how to get the path to DOS instead of the path to Windows ), however, the one who sets the path to the current directory asks a special question.
command-line windows batch-file short-filenames long-filenames
user1251007 Apr 19 '12 at 11:35 2012-04-19 11:35
source share