JSI Tip 2985. How can I get a list of files that do not conform to the 8.3 naming convention?


Using the technique in tip 0494, it should be have been easy to accomplish this, by just comparing the short file name (SFN) to the long file name (LFN), and it was, for the files in the root of the drive. Due to a parser error, it turned out to be more complicated.

To use LFN.BAT:

LFN <DriveLetter:>

Example: LFN C:

LFN.BAT contains:

@echo off
setlocal
if \[%1\]==\[\] goto syntax
set drive=%1if not exist %drive% goto syntax
cd /d %drive%
set output=%drive%$$lfn.txt
@echo \[%drive%\]>%output%
for /f "tokens=*" %%i in ('dir /b /a-d') do (
 if /i "%%~snxi" NEQ "%%i" echo %drive%%%i>>%output%)
FOR /f "tokens=*" %%q IN ('dir /b /ad /s') do call :sub "%%q"
endlocal
goto end
:syntax
@echo Command syntax: lfn Drive: (lfn c:)
endlocal
goto end
:sub
set folder=%1
set folder=%folder:"=%
pushd "%folder%"
for /f "tokens=*" %%i in ('dir /b /a-d') do set file=%%i&call :sub2 %%i
popd
goto end
:sub2
if /i "%file%" NEQ "%1" echo %folder%\%file%>>%output%&goto end
set work1=%file:~0,9%
set work2=%work1:.=%
if /i "%work1%" EQU "%work2%" echo %folder%\%file%>>%output%&goto end
set short=%~snx1
If "%file%" EQU "%short%" goto end
set work=%short:^~=%
If "%work%" EQU "%short%" goto end
echo %folder%\%file%>>%output%
:end

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish