Is there a way for me to search all files and have the results tell me what files DO NOT have what I'm searching for in them?
Or can I restrict a search to only search the first line of every file somehow?
I have a lot of "redirected" files in my HTML folder that only have one line in them. It is a <!--#include virtual="..." --> line. If I could either search for </body> and get every file that doesn't have that tag or if I could search for every file that has the include on line one then I would have a list of all files in my HTML directory that I need to take care of.
Any ideas or suggestions would be appreciated.
(I have done a file count only search on the include directive and I can go through that list and look at every file who only has this in them once, but it is very tedious. I have thousands of HTML files in this directory.)
Thanks,
Ken
Search for something NOT there
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
- talleyrand
- Posts: 624
- Joined: Mon Jul 21, 2003 6:56 pm
- Location: Kansas City, MO, USA
- Contact:
Hmmmm I suppose you could try a regular expression in the Find In Files thing. (just NOT whatever you're looking for)
So what is it exactly you are trying to do? Identify/open all the one liner html files or the html files that aren't one-liners? If the reg exp wizards don't come up with something I could probably rip a 10 line Python script out to do it for you.
So what is it exactly you are trying to do? Identify/open all the one liner html files or the html files that aren't one-liners? If the reg exp wizards don't come up with something I could probably rip a 10 line Python script out to do it for you.
I choose to fight with a sack of angry cats.
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact:
If the files in question contain only one line, could you filter them by file size?
Otherwise, If you are comfortable with command-line tools here are some ideas:
FINDSTR comes with at least Windows XP and has two switches that might help:
/V Prints only lines that do not contain a match.
/M Prints only the filename if a file contains a match.
(Run findstr /? from the command prompt for more info.)
The GREP tool from UNIX is a better choice, but you need to download it:
http://unxutils.sourceforge.net/ You might have to download the entire 3 MB package to get GREP, though.
Run grep --h for syntax help. This switch look promising:
-L, --files-without-match only print FILE names containing no match
Good luck
Otherwise, If you are comfortable with command-line tools here are some ideas:
FINDSTR comes with at least Windows XP and has two switches that might help:
/V Prints only lines that do not contain a match.
/M Prints only the filename if a file contains a match.
(Run findstr /? from the command prompt for more info.)
The GREP tool from UNIX is a better choice, but you need to download it:
http://unxutils.sourceforge.net/ You might have to download the entire 3 MB package to get GREP, though.
Run grep --h for syntax help. This switch look promising:
-L, --files-without-match only print FILE names containing no match
Good luck
The command line idea was very helpful
That would work very good and would have been quicker than what I did.
I wanted to return every one-liner html file with just that include statement in it. All of those files would not contain any other html so they would not have a </body> tag, which I thought would have been a good one to use to filter out whole html files.
But, I couldn't figure out the regular expression to say "not found."
I just did a search on the include string that appears on the first line. It appears on lots of other lines in the bigger files, but never on line one. Since TextPad returns results line-by-line with line numbers then I just did a search within the results on ".html(1)" which gave me the files I was looking for. It wasn't quick but it got me there.
The command line thing would have been much better and I'll keep that in mind for next time.
And hey, thanks for volunteering to create a Python script for me. That's amazing to me that you'd want to go to that much trouble, I appreciate that.
I wanted to return every one-liner html file with just that include statement in it. All of those files would not contain any other html so they would not have a </body> tag, which I thought would have been a good one to use to filter out whole html files.
But, I couldn't figure out the regular expression to say "not found."
I just did a search on the include string that appears on the first line. It appears on lots of other lines in the bigger files, but never on line one. Since TextPad returns results line-by-line with line numbers then I just did a search within the results on ".html(1)" which gave me the files I was looking for. It wasn't quick but it got me there.
The command line thing would have been much better and I'll keep that in mind for next time.
And hey, thanks for volunteering to create a Python script for me. That's amazing to me that you'd want to go to that much trouble, I appreciate that.