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

Jerold Schulman

November 1, 2000

1 Min Read
ITPro Today logo in a gray background | ITPro Today


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

Example: LFN C:

LFN.BAT contains:

@echo offsetlocalif [%1]==[] goto syntaxset drive=%1if not exist %drive% goto syntaxcd /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"endlocalgoto end:syntax@echo Command syntax: lfn Drive: (lfn c:)endlocalgoto end:subset folder=%1set folder=%folder:"=%pushd "%folder%"for /f "tokens=*" %%i in ('dir /b /a-d') do set file=%%i&call :sub2 %%ipopdgoto end:sub2if /i "%file%" NEQ "%1" echo %folder%%file%>>%output%&goto endset work1=%file:~0,9%set work2=%work1:.=%if /i "%work1%" EQU "%work2%" echo %folder%%file%>>%output%&goto endset short=%~snx1If "%file%" EQU "%short%" goto endset work=%short:^~=%If "%work%" EQU "%short%" goto endecho %folder%%file%>>%output%:end


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.

You May Also Like