GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Fast search with Everything

Just curious, why the leading underscores in your new switches?

Same reason as the $ signs before the command names? :slight_smile:

I had quite a few user commands written before the advent of VB/JS scripting support so the $ prefix was initially a visual means of identifying scripts which then became a habit. $es is the first time I have really explored the flexibility of using a /m (multi) variable. I initially wanted to eschew /s switches altogether so I could just pass any stream of arguments without any danger of crossing paths with a named switch. When I later decided that some switches might be handy I thought I would use an unlikely prefix to minimise the risk.


Regards, AB

March 10th, 2016. Updated to v1.4.

[ol]
[li]Added __update switch.[/li]
[li]Allow layout of collection columns via script configuration.[/li]
[li]Make temp file location configurable. Default to /temp if not configured.[/li]
[li]Extend placement default to disable all panels - e.g. tree, viewer, etc.[/li]
[li]Add default post DOpusRT delay and ability to adjust via script configuration.[/li][/ol]
[ol]
[li]Example: $es ext:ocb dm:today __update will append the results to an existing Everything collection.[/li]
[li]You can now configure your preferred columns and column order. e.g. modified,sizeauto,name,path. If you leave the field blank your normal default Collection format will apply.[/li]
[li]The location of temp files is now configurable.[/li]
[li]The placement default (see root post) disables tree, viewer, utility panel, etc.[/li]
[li]The Everything collection is created or updated using DOpusRT. In some situations a short delay is required to make sure that subsequent internal commands complete successfully. The default of 250ms works well for me.[/li][/ol]
Regards, AB

March 15th, 2016. Updated to v1.6.

[ol]
[li]v1.5 fixed a missing comma before "norm" in the def_placement definition.[/li]
[li]v1.6 Uses codepage 1252 to handle non-ASCII characters in file names.[/li][/ol]
Regards, AB

I'm using DOpus 11.18 and it didn't like $es.js.v1.6.txt as a filename for dropping onto the Preferences -> Scripts pane.

Also, note, since '$' is a reserved character in URI spec, this gets downloaded as %24es.js.v1.6.txt. I first renamed it to $es.js.v1.6.txt only to find it doesn't work. Then I renamed it to $es.js.txt and it worked. Since the '$' bugs me and makes no sense at all, I'm going to remove it anyway. :smiley:

Thank you for this great script.

Glad you like the script. Maybe when (if) there is another update it will be a good time for me to move on from the $ prefix thing. :smiley:

Regards, AB

Thanks you very much, this is a very useful script, and it is exactly what I need. :slight_smile:

The script seems to work fine except several cases:

1) When I use NEWTAB in def_placement it returns this:

 14.02.2017 9:39 $es:  info(1): Original command line = $es test
 14.02.2017 9:39 $es:  info(1): es.exe located in C:\Program Files\everything\es.exe
 14.02.2017 9:39 $es:  info(1): promptuser = false
 14.02.2017 9:39 $es:  info(1): updatecoll = false
 14.02.2017 9:39 $es:  info(1): updatecoll = false
 14.02.2017 9:39 $es:  info(1): Search Criteria = test
 14.02.2017 9:39 $es:  info(1): Transformed search criteria = test
 14.02.2017 9:39 $es:  info(2): tmp_path = C:\Users\User\AppData\Local\Temp
 14.02.2017 9:39 $es:  info(2): (runshell): tmp_cmd = C:\Users\User\AppData\Local\Temp\$es.cmd
 14.02.2017 9:39 $es:  info(3): DOpusRT import command = /home\dopusrt.exe /col import /clear /create everything "C:\Users\User\AppData\Local\Temp\$es.out"
 14.02.2017 9:39 $es:  info(3): cmdstring = Go Coll://Everything NEWTAB USEQUALKEYS
 14.02.2017 9:39 $es:  Error at line 215, position 51
 14.02.2017 9:39 $es:  Object doesn't support this property or method (0x800a01b6)

  1. When symbols from Western European charset are used for search query nothing happens:
 14.02.2017 9:48 $es:  info(1): Original command line = $es prüfung
 14.02.2017 9:48 $es:  info(1): es.exe located in C:\Program Files\everything\es.exe
 14.02.2017 9:48 $es:  info(1): promptuser = false
 14.02.2017 9:48 $es:  info(1): updatecoll = false
 14.02.2017 9:48 $es:  info(1): updatecoll = false
 14.02.2017 9:48 $es:  info(1): Search Criteria = prüfung
 14.02.2017 9:48 $es:  info(1): Transformed search criteria = prüfung
 14.02.2017 9:48 $es:  info(2): tmp_path = C:\Users\User\AppData\Local\Temp
 14.02.2017 9:48 $es:  info(2): (runshell): tmp_cmd = C:\Users\User\AppData\Local\Temp\$es.cmd

or from Cyrillic charset

 14.02.2017 9:55 $es:  info(1): Original command line = $es проверка
 14.02.2017 9:55 $es:  info(1): es.exe located in C:\Program Files\everything\es.exe
 14.02.2017 9:55 $es:  info(1): promptuser = false
 14.02.2017 9:55 $es:  info(1): updatecoll = false
 14.02.2017 9:55 $es:  info(1): updatecoll = false
 14.02.2017 9:55 $es:  info(1): Search Criteria = проверка
 14.02.2017 9:55 $es:  info(1): Transformed search criteria = проверка
 14.02.2017 9:55 $es:  info(2): tmp_path = C:\Users\User\AppData\Local\Temp
 14.02.2017 9:55 $es:  info(2): (runshell): tmp_cmd = C:\Users\User\AppData\Local\Temp\$es.cmd

3) When symbols from Japanese charset are used for search query the script returns this error:

 14.02.2017 10:00 $es:  info(1): Original command line = $es 試験
 14.02.2017 10:00 $es:  info(1): es.exe located in C:\Program Files\everything\es.exe
 14.02.2017 10:00 $es:  info(1): promptuser = false
 14.02.2017 10:00 $es:  info(1): updatecoll = false
 14.02.2017 10:00 $es:  info(1): updatecoll = false
 14.02.2017 10:00 $es:  info(1): Search Criteria = 試験
 14.02.2017 10:00 $es:  info(1): Transformed search criteria = 試験
 14.02.2017 10:00 $es:  info(2): tmp_path = C:\Users\User\AppData\Local\Temp
 14.02.2017 10:00 $es:  info(2): (runshell): tmp_cmd = C:\Users\User\AppData\Local\Temp\$es.cmd
 14.02.2017 10:00 $es:  Error at line 380, position 33
 14.02.2017 10:00 $es:  Invalid procedure call or argument (0x800a0005)

For some reason the head post is not showing up as editable so I can't post an updated version with a fix for NEWTAB. If you are OK to do this yourself, edit line 215 and remove .tabs(0) from the end of the statement. The revised statement should be:

else if (0<d.func.command.results.newtabs.count) d.func.command.SetSourceTab(d.func.command.results.newtabs(0));

With that fix in place, >$es prüfung worked for me.

Regards, AB

Editing of old posts isn't enabled yet on the new forum, but will be once we get to organising the downloads area. Hopefully this week.

Thanks.
I changed the lines mentioned above and it seems to fix NEWTAB issue, but the problem with symbols from different charsets still occur. And as far as I can see, the way it behaves on particular system depends on system default charset, Windows Latin (1252) in your case and Windows Cyrillic (1251) in my case. I've managed to make it accept Cyrillic symbols by changing code page from 1252 to 1251 in the line a[a.length] = "chcp 1252"; , WE symbols(e.g. prüfung) still are not accepted, the same happens with Japanese kanji(same error as in my previous post).

Here are my cmd and out files with codepage set to 1252.
$es.cmd

pushd C:\Program Files\everything
chcp 1252
es.exe prufung > C:\Users\User\AppData\Local\Temp\$es.out
popd

$es.out

C:\test\prьfung.txt

$es.cmd

pushd C:\Program Files\everything
chcp 1252
es.exe проверка > C:\Users\User\AppData\Local\Temp\$es.out
popd

$es.out null output


And the same search query with code page set to 1251.
$es.cmd

pushd C:\Program Files\everything
chcp 1251
es.exe prufung > C:\Users\User\AppData\Local\Temp\$es.out
popd

$es.out

C:\test\prufung.txt

$es.cmd

pushd C:\Program Files\everything
chcp 1251
es.exe проверка > C:\Users\User\AppData\Local\Temp\$es.out
popd

$es.out

C:\test\проверка.txt

My default code page is 850. I originally forced 1252 to deal with non-ASCII Western European characters but as you point out that won't work for everyone. I will add a code page configuration option and post an update once I'm able to edit the head post. Maybe someone who is more familiar with this could advise if there is a better way.

Regards, AB

Thanks.

is the content of the OP the most up-to-date for this?

It turns out it wasn't. I have updated to v1.7 in the head post.

Since posting this code a long time ago I have actually rewritten from scratch, to leverage enhancements in newer versions of es.exe and a better grasp of JavaScript and DOpus objects. From memory I don't think there is any new functionality but when time permits I'll have a look and possibly post.

I installed your script and find it to be a valuable addition to Opus, well done! I have a question for you, however. When I do a search for a file that exists on my computer, it works well, and as it should.

When I search for a file that is not on my computer, it seems as if it does nothing. I realize that in the background it is actually performing the search, and that the results come up empty. But when it first happened to me, I thought the program es.exe or maybe your script had stopped working as they should. There was simply no indication that the search came up empty, or that the search was even performed.

Is there a way to alter the script so that a search that yields no results at least opens the coll:everything pane and shows that there are no results?

I am reluctant to make that change in the current code. I plan to publish version 2 in the not too distant future and I will make it a configurable option. In the meantime, if you delete or comment out (add a // prefix) line 209 that will do what you want.

1 Like

Thank you! Commenting out line 209 does indeed return an empty lister.

I'm not sure how you could improve on this script, but I do look forward to finding out!!

Thanks for the script.But I'm kinda having trouble making this button into a search toolbar... I'd really appreciate it if you could help me out

I have posted a rewrite here. A set of sample buttons is included.