8.3 Old-DOS Short-Format PATH - Drag&Drop Support!

Posted at




@echo off
::might be relative|short|full|...whatever... (take it as is)
set FILE_INPUT=%~1
if [%FILE_INPUT%] == [] ( goto NOFILE )

::placeholder
set FILE_INPUT_FULL_RAW=""
set FILE_INPUT_FULL_SHORT=""

:: "f"=convert to a fully qualified path, with standard naming (if input is short naming, might still look like short-naming).
for /f %%a in ("%FILE_INPUT%")do (set "FILE_INPUT_FULL_RAW=%%~fa" )
:: "s"=convert to a fully qualified path, with 8.3-naming "short-DOS-naming".
for /f %%a in ("%FILE_INPUT%")do (set "FILE_INPUT_FULL_SHORT=%%~fsa" )

echo.
echo.
echo %FILE_INPUT_FULL_RAW%
echo ^=^=^=^>^>^>
echo %FILE_INPUT_FULL_SHORT%

goto EXIT


:NOFILE
echo.
echo.
echo ERROR: Argument missing.
echo Please supply a file or folder path (relative or full),
echo You may also simply drag^&drop any file or folder over this batch file to make it work..
goto EXIT

:EXIT
echo.
echo.
pause



Also at this GitHub's GIST:
https://gist.github.com/eladkarako/a250e2daa2f67a40437ecfae3d7641de
', 'Any Relative PATH To A Fully Qualified