Jerold Schulman
Guest
|
Posted:
Fri Sep 24, 2004 6:24 pm Post subject:
Re: Any way to convert long file name to short file name fro |
|
|
On Thu, 23 Sep 2004 15:38:20 -0700, "Peter Steele" <psteele@z-force.com> wrote:
| Quote: | 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?
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 |
|