Mombu the Microsoft Forum sponsored links

Go Back   Mombu the Microsoft Forum > Microsoft > Any way to convert long file name to short file name from cmd line?
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 24th April 19:29
peter steele
External User
 
Posts: 1
Default Any way to convert long file name to short file name from cmd line?


I'd like to be able to take a long file name like

C:\Program Files\LongAppName

and convert it to its equivalent short file name from the command line. For
example if %LNAME% contained the long file name, I'd like to assign %SNAME%
the short file name equivalent. Can this be done without having to resort to
writing an app? Any freebie tools available for this?
  Reply With Quote


  sponsored links


2 24th April 19:30
jerold schulman
External User
 
Posts: 1
Default Any way to convert long file name to short file name from cmd line?


I just wrote the following script:
You would:
call cvtlfnsfn %lname% sname


@echo off
if {%2}=={} @echo Syntax: CvtLFNSFN LFN SFN&goto :EOF setlocal set file=%~nx1
@echo.>"%TMP%\%file%"
:loop
for /f "Tokens=1* Delims=\" %%a in ('dir "%TMP%\%file%" /X^|find "%file%"') do (
set line=%%a
)
del /q "%TMP%\%file%"
for /f "Tokens=1*" %%a in ('@echo %line:~36%') do (
set sfm=%%a
)
endlocal&set %2=%sfm%

Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666