AHK to search for file contents? Like Grep
AHK to search for file contents? Like Grep
I need to search file contents. 99% of the time CSV files.
Windows explorer has a setting when searching that allows you to search file contents.
This is great. Except it doesn't always work.
I've used Grep in the past. That was a long time ago.
I don't actually want to install Grep.
But then just wondering if I could use AHK to do what Grep does?
How efficient would it be?
In my folders, I'd have say 10,000 CSV files - all less than 10kb.
Or should I think of using Python instead?
Thanks.
Windows explorer has a setting when searching that allows you to search file contents.
This is great. Except it doesn't always work.
I've used Grep in the past. That was a long time ago.
I don't actually want to install Grep.
But then just wondering if I could use AHK to do what Grep does?
How efficient would it be?
In my folders, I'd have say 10,000 CSV files - all less than 10kb.
Or should I think of using Python instead?
Thanks.
Re: AHK to search for file contents? Like Grep
Not an AHK solution, but I've had good results with SearchMyFiles from NirSoft.
Russ
Russ
Re: AHK to search for file contents? Like Grep
Total Commander and lots of other programs can also search files on the fly. If you want something very fast, you'd probably need a program that indexes your files. There are lots of those, too, like dtSearch. That said, small CSV files could be read very quickly by just about any program, including AHK. You could also write a script that indexes your files and then retrieves them quickly.
Re: AHK to search for file contents? Like Grep
SearchMyFiles looks good.
Looks like ancient Windows interface - but if it does the job, great
Very small
File indexing?
Hmmm... how much overhead does that use up?
I'd consider if no real impact on my laptop
Let me know
Thanks
In anycase... AHK solution maybe would not be good...
I need a GUI interface to open files after searches!
Looks like ancient Windows interface - but if it does the job, great
Very small
File indexing?
Hmmm... how much overhead does that use up?
I'd consider if no real impact on my laptop
Let me know
Thanks
In anycase... AHK solution maybe would not be good...
I need a GUI interface to open files after searches!
Re: AHK to search for file contents? Like Grep
I use dtSearch to index my entire computer (updated document files only) every night. I have no idea how much overhead it uses, because I'm always asleep when it's doing the work.
Re: AHK to search for file contents? Like Grep
search for files > Everything
https://www.voidtools.com/
search for files / words in file > XSearch
https://www.easexp.com/xsearch/
https://www.voidtools.com/
search for files / words in file > XSearch
https://www.easexp.com/xsearch/
Re: AHK to search for file contents? Like Grep
The technique of choice (e.g., indexing or not) depends on the situation: how often searches are done, the scope of a typical search, and the extent to which search time matters. Infrequent searches of smaller scope or smaller files may not benefit much from indexing, compared to larger or more frequent searches. I use both techniques together: Total Commander for my narrow and smaller searches, and dtSearch when I need to search hundreds or thousands of long documents at once. An advanced program like dtSearch has some additional features: can search for synonyms, misspellings, dates and numbers in certain ways, words near other specific words, plurals or stemming, and even words that sound similar.
Re: AHK to search for file contents? Like Grep
dtsearch seems professional
- flyingDman
- Posts: 2817
- Joined: 29 Sep 2013, 19:01
Re: AHK to search for file contents? Like Grep
I am often surprised about AHK's file-reading speed. So I tested this. I made a folder with 10,000 csv files, each consisting of random words (from a 280k wordlist) . 100 rows and 10 columns. Each file is about 10K. Then, with a simple loop and using instr to search, I searched through each file. The results are impressive again. About 500 ms to search all occurrences of the search term. AHK is highly capable to do this.
Search script:
Make 10,000 csv files (this takes about 30 minutes on my PC):
Search script:
Code: Select all
st := A_TickCount
loop, 10000
{
fileread, oVar, %a_scriptdir%\csvfolder\csv%a_index%.csv
if (instr(oVar,"fast")) ; change the search term here
lst .= a_scriptdir "\csvfolder\csv" a_index ".csv`n"
}
msgbox % a_tickcount - st "`n`n" lst
Code: Select all
fileread, var, C:\Users\xxx\Scripts\Wordlist_280K.txt
arr := strsplit(var,"`n","`r")
loop, 10000
{
i := a_index
loop, 1000
{
random, rndm, 1, 280000
fileappend, % mod(a_index,10) = 0 ? arr[rndm] "`n" : arr[rndm] ",", %a_scriptdir%\csvfolder\csv%i%.csv
}
}
14.3 & 1.3.7