Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
September 27, 2004
I have scripted CvtLFNSFN.bat to convert a LFN (Long File Name) to a SFN (Short File Name).
NOTE: LFN refers to the file name and extension, NOT to the folder path.
The syntax for using CvtLFNSFN.bat is:
CvtLFNSFN LFN SFN
Where LFN can be the LFN or the FQFN (Fully Qualified File Name), and SFN is a call directed environment variable that will contain the SFN.
NOTE: Neither the LFN nor the FQFN has to exist.
CvtLFNSFN.bat contains:
@echo offif {%2}=={} @echo Syntax: CvtLFNSFN LFN SFN&goto :EOFsetlocalset file=%~nx1@echo.>"%TEMP%%file%":loopfor /f "Tokens=1* Delims=" %%a in ('dir "%TEMP%%file%" /X^|find "%file%"') do ( set line=%%a)del /q "%TEMP%%file%"for /f "Tokens=1*" %%a in ('@echo %line:~36%') do ( set sfm=%%a)endlocal&set %2=%sfm%
You May Also Like