Seach files for empty text documents

Find, replace, find in files, replace in files, regular expressions

Seach files for empty text documents

Postby pmcneel » Sun Dec 03, 2006 10:37 pm

How can I use UltraEdit to search a directory for files that contain NO text (or that contain only a few characters)?

Idealy I would like to develop a word/character count for each file in a directory.
User avatar
pmcneel
Newbie
 
Posts: 3
Joined: Sun Dec 03, 2006 12:00 am

Re: Seach files for empty text documents

Postby Mofi » Mon Dec 04, 2006 9:55 am

UltraEdit is a text editor and not a file manager. To search for files with less than xx bytes use Windows Explorer or Total Commander.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4055
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Seach files for empty text documents

Postby pmcneel » Mon Dec 04, 2006 5:12 pm

Thanks for the tip. Document size alone, however, doesn't help me.

The reason I need a text editor it to search large directories of text files and identify those with no text. Some may have only line breaks and spaces and be well over 1KB in size but contain no text.
User avatar
pmcneel
Newbie
 
Posts: 3
Joined: Sun Dec 03, 2006 12:00 am

Re: Seach files for empty text documents

Postby Mofi » Tue Dec 05, 2006 12:27 pm

Well, Total Commander has very good search capabilities. With TC you can search for files with size less than xx bytes and does NOT contain a specified text. The specified text can be also a Perl regular expression. So with Total Commander you will easily get the list of files you want.

To do this with UltraEdit needs much of work.

First you must get a list of all files in your directories. This can be done since UE v9.10 with a Find In Files with an empty search string with results to an edit window.

Next you have to run on same files a regular expression search to find the files which contain words with at least x characters. This is also a Find In Files search with results to an edit window. From this result you have to delete everything except the file names with full path and sort the file with removing duplicate file names because a word is surely found more than once in a file. I have posted already a macro which does this job - macro depends on your version of UltraEdit.

Now you have 2 lists with file names: First list contains all files and second list contains all files with at least 1 word (or more - depends on your macro which evaluates the search result) which has at least x characters.

You can now remove with a macro all file names from list 2 in the list of file 1 and the result should be a list of files which does not have (enough) words.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4055
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Seach files for empty text documents

Postby pmcneel » Tue Dec 05, 2006 7:34 pm

Thanks to Mofi for the new toy! (I mean tool...)

I can use Total Commander to search for text NOT in the file, search for [0-9a-z] using RegEx, giving me a list of all documents with out meaningful text, which is exactly what I want.
User avatar
pmcneel
Newbie
 
Posts: 3
Joined: Sun Dec 03, 2006 12:00 am


Return to Find/Replace/Regular Expressions