JSI Tip 7943. How can I report all file names that exceed a given length?


I have scripted LFNGTR.bat to report all file names that exceed a specified number of characters.

The syntax for using LFNGTR.bat is:

lfngtr DriveLetter NumberOfCharacters

where DriveLetter is the drive letter of the partition you wish to search, and NumberOfCharacters is the number of characters that must be exceeded for the file name to be reported on the console.

NOTE: To report to a file, use lfngtr DriveLetter NumberOfCharacters>ReportFile

NOTE: LFNGTR.bat uses VarLen.bat.

LFNGTR.bat contains:

@echo off
setlocal
if \{%2\}==\{\} goto error
set drive=%1
set drive=%drive:~0,1%:\*.*
set /a size=100000%2%%100000
for /f "Tokens=*" %%a in ('dir %drive% /b /s') do call :full "%%a"
endlocal
exit /b 0
:error
@echo Syntax: LFNGTR DriveLetter FileSize
endlocal
exit /b 1
:full
set folder=%~DP1
set file=%~nx1
call varlen file len
if %len% GTR %size% @echo File: "%file%" Path: "%folder%"



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