Way to open multiple "New Search Window"s from a list of search expressions or a .csv file

General discussion related to "Everything".
Post Reply
stevenroussos
Posts: 22
Joined: Wed Apr 08, 2015 10:00 pm

Way to open multiple "New Search Window"s from a list of search expressions or a .csv file

Post by stevenroussos » Wed Mar 28, 2018 11:15 pm

I use Everything a lot, for multiple concurrent things, sometimes ending up with dozens of Search Windows open.

When it is necessary to reboot the computer I take care to properly CLOSE the Everything app so that all my open searches are saved in the Search History.csv file.

So, after restarting, I can of course look at the SearchHistory.csv file, AND/OR I can use View/Goto/AllSearchHistory and sort by "Last Searched".

HOWEVER: even though in the AllSearchHistory window you can select multiple lines at once, when you click OPEN only the last line touched is opened.

Therefore if I want to get back to my previous state of having the same many Search Windows open, the only option is to manually go to each former search expression in the History window and click open one by one.

VERY TIME CONSUMING!

Is there any way at all, perhaps by starting Everything from a command line and feeding it perhaps an edited SearchHistory.csv file and cause it to AUTOMAGICALLY open as many new Search Windows as I wish, each containing one of the provided search expressions.

That would be REALLY useful! (OR... if there was a way to select >1 in the Search History window and have OPEN button recognize that the user wants ALL of those former searches to be performed and opened in its own new search window, which would accomplish the same thing.)

THANKS FOR ANY SUGGESTIONS!

therube
Posts: 1982
Joined: Thu Sep 03, 2009 6:48 pm

Re: Way to open multiple "New Search Window"s from a list of search expressions or a .csv file

Post by therube » Thu Mar 29, 2018 2:43 pm

(Session Restore in Mozilla speak.
Yes, at times, I too would like to be able to Quit & save [Bookmark] each session window & each window's individual [back/fwd] histories too.)

NotNull
Posts: 917
Joined: Wed May 24, 2017 9:22 pm

Re: Way to open multiple "New Search Window"s from a list of search expressions or a .csv file

Post by NotNull » Thu Mar 29, 2018 4:41 pm

stevenroussos wrote: Is there any way at all, perhaps by starting Everything from a command line and feeding it perhaps an edited SearchHistory.csv file and cause it to AUTOMAGICALLY open as many new Search Windows as I wish, each containing one of the provided search expressions.
Here is a Powershell script that should do what (I think it is) you want:
  • Read "Search History.csv"
  • Detect the most recent entry
  • Get all entries that have a Last Search Date less than 24 hours older compared to the most recent one
  • Manipulate the entries (command-line requires escaping of special chatacters)
  • For each entry: start a new Everything window with this query and wait 2 seconds before proceeding to the next entry.
Put LoadHistory.ps1 in the folder where your Everything.exe and "Search History.csv" are.


LoadHistory.ps1

Code: Select all

$DB = import-csv '.\Search History.csv'

$History = ($DB | sort -property 'Last Search Date' -descending)

$lastactive = $history[0].'Last Search Date'
$daybefore = ($mostrecent  - 1000000000*60*60*24)

$recent = ($History | where -Property 'Last Search Date' -gt $daybefore)

foreach ($Query in $recent) {
	$search = (-join ("-newwindow -search " , "`"" , ($Query.Search).Replace('"','"""') , "`""))
	sleep 2
	#Start-process .\everything.exe -Argumentlist "$search"
}
P.S. I thought I could do this quickly (as in: couple of minutes), but I had a hard time handling quotes, double quotes, etc. Glad I'm not a developer :D

stevenroussos
Posts: 22
Joined: Wed Apr 08, 2015 10:00 pm

Re: Way to open multiple "New Search Window"s from a list of search expressions or a .csv file

Post by stevenroussos » Thu Mar 29, 2018 5:19 pm

THANK YOU!

My intent will be to copy the main .csv file and edit it to include entries to my wishes, which might include searches older than the last day.

In which case I guess I will edit the input file name to the name of the copy with my edited want list, then change

foreach ($Query in $recent) {

to

foreach ($Query in $DB) {

Does that sound right?

NotNull
Posts: 917
Joined: Wed May 24, 2017 9:22 pm

Re: Way to open multiple "New Search Window"s from a list of search expressions or a .csv file

Post by NotNull » Thu Mar 29, 2018 5:52 pm

Wish I knew that before ... In that case, you can get rid of a lot of overhead:

LoadHistory.ps1

Code: Select all

Param(
  [Parameter(Mandatory=$True,Position=1)]
   [string]$csv-file
)


import-csv $csv-file | foreach {
	$search = (-join ("-newwindow -search " , "`"" , ($_.Filename).Replace('"','"""') , "`""))
	sleep 2
	Start-process .\everything.exe -Argumentlist "$search"
}

Now you can drag the CSV file to this script to load the entries.
-or-
Start it with: LoadHistory.ps1 "My CSV file.csv"
-or-
Start the script without parms; it will ask for a filename

stevenroussos
Posts: 22
Joined: Wed Apr 08, 2015 10:00 pm

Re: Way to open multiple "New Search Window"s from a list of search expressions or a .csv file

Post by stevenroussos » Thu Mar 29, 2018 7:24 pm

THANKS A MILLION! You should send this to VOIDTOOLS creator so it can be included in future releases. VERY handy!

NotNull
Posts: 917
Joined: Wed May 24, 2017 9:22 pm

Re: Way to open multiple "New Search Window"s from a list of search expressions or a .csv file

Post by NotNull » Thu Mar 29, 2018 7:53 pm

You're welcome! But mostly, you should thank @void. He made this all possible...

I have to thank you too, btw. I want to get more fluent in Powershell. Questions like this are a good practice for that and also a lot of fun (apart from those <insert at least 10 curse words here> quotes ...)
stevenroussos wrote:You should send this to VOIDTOOLS creator so it can be included in future releases. VERY handy!
I think @void follows closely what's going on in these forums ...

void
Site Admin
Posts: 4197
Joined: Fri Oct 16, 2009 11:31 pm

Re: Way to open multiple "New Search Window"s from a list of search expressions or a .csv file

Post by void » Thu Apr 05, 2018 9:46 am

Added to my TODO list: restore previous session (support multiple windows) and allow user to open search history in existing window or new window.


stevenroussos
Posts: 22
Joined: Wed Apr 08, 2015 10:00 pm

Re: Way to open multiple "New Search Window"s from a list of search expressions or a .csv file

Post by stevenroussos » Fri Oct 19, 2018 9:00 pm

Did you ever add a restore previous session function?

void
Site Admin
Posts: 4197
Joined: Fri Oct 16, 2009 11:31 pm

Re: Way to open multiple "New Search Window"s from a list of search expressions or a .csv file

Post by void » Sat Oct 20, 2018 12:12 am

It is still on my TODO list.

Post Reply