Page 1 of 1

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

Posted: Wed Mar 28, 2018 11:15 pm
by stevenroussos
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!

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

Posted: Thu Mar 29, 2018 2:43 pm
by therube
(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.)

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

Posted: Thu Mar 29, 2018 4:41 pm
by NotNull
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

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

Posted: Thu Mar 29, 2018 5:19 pm
by stevenroussos
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?

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

Posted: Thu Mar 29, 2018 5:52 pm
by NotNull
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

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

Posted: Thu Mar 29, 2018 7:24 pm
by stevenroussos
THANKS A MILLION! You should send this to VOIDTOOLS creator so it can be included in future releases. VERY handy!

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

Posted: Thu Mar 29, 2018 7:53 pm
by NotNull
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 ...

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

Posted: Thu Apr 05, 2018 9:46 am
by void
Added to my TODO list: restore previous session (support multiple windows) and allow user to open search history in existing window or new window.

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

Posted: Thu Apr 05, 2018 3:18 pm
by stevenroussos
Cool, thanks!

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

Posted: Fri Oct 19, 2018 9:00 pm
by stevenroussos
Did you ever add a restore previous session function?

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

Posted: Sat Oct 20, 2018 12:12 am
by void
It is still on my TODO list.

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

Posted: Mon Sep 30, 2019 1:14 am
by stevenroussos
Still "to do"? Seems like it should be fairly straightforward, but I realize you have a mountain of requests/tasks. But this would surely be one of the most useful & appreciated enhancements. Just a simple "restore last session." Other things like a list of previous-session searches and the ability to select/deselect as desired and an "Open" button would finesse it, but just a basic 1 shot "Restore Previous Session" would be loved by MANY I am sure.

THANKS!