On Wednesday 10/10/2012 22:15,
alber...@gmail.com wrote:
>> It seems that you have a lot of text files and inside some of the text files are lines that exceed 32
>> KB. You wish to find the lines that exceed 32,000 characters, is that right?
>>
>
> Exactly. At least one of the lines of each file hace a length of 32000 characters.
I cobbled together some VBS scripts that I found as batch alone is unsuited for this task.
This reports the filenames and the first line number that exceeds 32000
Execute it with: findlines.bat "c:\data folder"
and it will search the current folder and subdirectories.
@echo off
if "%~1"=="" (
echo finds files with lines greater than 32,000 characters
echo SYNTAX: "%~nx0" [path]
pause
goto :EOF
)
(
echo Dim strPath
echo Set oFSO = CreateObject^("Scripting.FileSystemObject"^)
echo strPath = "%~1"
echo ' strPath = InputBox^("Enter Folder Path: "^)
echo ' Set fOut = oFSO.CreateTextFile^("%fileout%", True^)
echo DoStuff oFSO.GetFolder^(strPath^).Path
echo Sub DoStuff^(sDir^)
echo Set oDir = oFSO.GetFolder^(sDir^)
echo For Each i In oDir.Files
echo set fso=createobject("Scripting.Filesystemobject"^)
echo set tfin=fso.OpenTextFile(sDir + "\" + i.Name, 1^)
echo dontprint=0: linenum=0
echo Do While Not tfin.AtEndOfStream
echo linenum=linenum+1
echo line=(tfin.ReadLine^)
echo if (len(line^) ^> 32000 and dontprint=0^) then wscript.echo ^
"first line: " ^& linenum ^& " - " ^& sDir + "\" + i.Name ^
:dontprint=1
echo Loop
echo Next
echo For Each i In oDir.SubFolders
echo DoStuff i.Path
echo Next
echo End Sub
)>"%temp%\vbsfiledate.vbs"
cscript /nologo "%temp%\vbsfiledate.vbs"
del "%temp%\vbsfiledate.vbs"
:: copy "%temp%\vbsfiledate.vbs" .
pause
goto :EOF
--
foxi