Using the Python 3 Everything SDK wrapper

Plug-in and third party software discussion.
Post Reply
Tank Ersley
Posts: 11
Joined: Sat Aug 05, 2023 5:48 pm

Using the Python 3 Everything SDK wrapper

Post by Tank Ersley »

Hi. I've recently gone back to working with Python and ran across Everything.py. I've managed to make a script that takes a comma-separated string, turns it into a regex string and searches Everything.

Is there a way to use Search filters in Everything.py? Either ones that I've added in Everything or a list of extensions?

Also, is there a way to return all files listed in Everything?

I'm looking to do something like getting a list of the most recently downloaded video files.

Any help would be appreciated.

If this is the wrong forum, please let me know where this need to go.

Thanks.

Edited to add: Also, is there a way to get info on files that are highlighted in Everything?
void
Developer
Posts: 16665
Joined: Fri Oct 16, 2009 11:31 pm

Re: Using the Python 3 Everything SDK wrapper

Post by void »

Everything 1.5 will have support for accessing filters.

For now, please manually include the following in your search:

Audio:

Code: Select all

ext:aac;ac3;aif;aifc;aiff;amr;ape;au;cda;dts;fla;flac;it;m1a;m2a;m3u;m4a;m4b;m4p;mid;midi;mka;mod;mp2;mp3;mpa;mpc;ogg;opus;ra;rmi;snd;spc;voc;wav;weba;wma;xm
Compressed:

Code: Select all

ext:7z;ace;arj;bz2;cab;gz;gzip;jar;r00;r01;r02;r03;r04;r05;r06;r07;r08;r09;r10;r11;r12;r13;r14;r15;r16;r17;r18;r19;r20;r21;r22;r23;r24;r25;r26;r27;r28;r29;rar;tar;tgz;z;zip
Document:

Code: Select all

ext:c;cc;chm;cpp;cs;css;csv;cxx;doc;docm;docx;dot;dotm;dotx;epub;h;hpp;htm;html;hxx;ini;java;js;json;lua;md;mht;mhtml;mobi;odp;ods;odt;pdf;php;potx;potm;ppam;ppsm;ppsx;pps;ppt;pptm;pptx;pub;py;rtf;sldm;sldx;thmx;txt;vsd;wpd;wps;wri;xlam;xls;xlsb;xlsm;xlsx;xltm;xltx;xml;vb
Executable:

Code: Select all

ext:bat;cmd;exe;msi;msp;msu;ps1;scr
Folder:

Code: Select all

folder:
Picture:

Code: Select all

ext:ani;apng;avci;avcs;avif;avifs;bmp;bpg;cur;gif;heic;heics;heif;heifs;hif;ico;jfi;jfif;jif;jpe;jpeg;jpg;pcx;png;psb;psd;rle;svg;tga;tif;tiff;webp;wmf
Video:

Code: Select all

ext:3g2;3gp;3gp2;3gpp;amv;asf;asx;avi;bdmv;bik;d2v;divx;drc;dsa;dsm;dss;dsv;evo;f4v;flc;fli;flic;flv;hdmov;ifo;ivf;m1v;m2p;m2t;m2ts;m2v;m4v;mkv;mp2v;mp4;mp4v;mpe;mpeg;mpg;mpls;mpv2;mpv4;mov;mts;ogm;ogv;pss;pva;qt;ram;ratdvd;rm;rmm;rmvb;roq;rpm;smil;smk;swf;tp;tpr;ts;vob;vp6;webm;wm;wmp;wmv


To get filenames with highlighted search terms, please see Everything_GetResultHighlightedFileName
Tank Ersley
Posts: 11
Joined: Sat Aug 05, 2023 5:48 pm

Re: Using the Python 3 Everything SDK wrapper

Post by Tank Ersley »

This is my query statement.

Code: Select all

Everything.Query(queryString=search_statement, maxResults=max_num_results)
How do I add a sort to the query? I've tried these and none of them work.

Code: Select all

sortOrder=SortOrder.AccessDate
sortOrder="SortOrder.AccessDate"
sortOrder=AccessDate
sortOrder="AccessDate"
sortOrder=23
sortOrder="23"
Also, how do I indicate ascending or descending?

If I have maxresults = 5, will it sort the entire list and then return the first 5 results from the sorted list, or get the first 5 results from the unsorted list and then sort those 5 results?
Tank Ersley
Posts: 11
Joined: Sat Aug 05, 2023 5:48 pm

Re: Using the Python 3 Everything SDK wrapper

Post by Tank Ersley »

I used ChatGPT to help get this to work. Yes, this a total kludge, so I hope someone can suggest a native means of doing this.

Code: Select all

from lib.c_defines import SortType
.
.
.
q = Everything.Query(queryString=search_statement, maxResults=max_num_results, sortOrder=SortType.EVERYTHING_SORT_DATE_CREATED_DESCENDING)
void
Developer
Posts: 16665
Joined: Fri Oct 16, 2009 11:31 pm

Re: Using the Python 3 Everything SDK wrapper

Post by void »

For Date Accessed, please try the following:

Code: Select all

Everything.Query("searched.txt", matchingOptions=Everything.QueryStringOptions.WholeWord, sortOrder=SortOrder.AccessDate)


For Date Modified, please try the following:

Code: Select all

Everything.Query("searched.txt", matchingOptions=Everything.QueryStringOptions.WholeWord, sortOrder=SortOrder.ModificationDate)


For Date Created, please try the following:

Code: Select all

Everything.Query("searched.txt", matchingOptions=Everything.QueryStringOptions.WholeWord, sortOrder=SortOrder.CreationDate)

Also, how do I indicate ascending or descending?
They don't appear to be defined in this third party py project.

Please try the following change to Everything.py:

Code: Select all

class SortOrder(enum.IntEnum):
    FilenameAscending = 1
    FilenameDescending = 2
    PathAscending = 3
    PathDescending = 4
    SizeAscending = 5
    SizeDescending = 6
    Extension = 7
    Type = 9
    CreationDateAscending = 11
    CreationDateDescending = 12
    ModificationDateAscending = 13
    ModificationDateDescending = 14
    Attributes = 15
    _FilelistFilename = 17
    _RunCount = 19
    _RecentlyChangedDate = 21
    AccessDateAscending = 23
    AccessDateDescending = 24
    _RunDate = 25
If I have maxresults = 5, will it sort the entire list and then return the first 5 results from the sorted list, or get the first 5 results from the unsorted list and then sort those 5 results?
Everything will do the sort after finding your results.
However, if sorting by a fast sort, the sort is done first. (for example, name, path, size or date modified)
Fast sorts are instant.
Tank Ersley
Posts: 11
Joined: Sat Aug 05, 2023 5:48 pm

Re: Using the Python 3 Everything SDK wrapper

Post by Tank Ersley »

I did the following.

Changes to Everything.py:

Modified the SortOrder class per your suggestion.

Changed this line in the Query class

Code: Select all

sortOrder: SortOrder = SortOrder.Filename
to this.

Code: Select all

sortOrder: SortOrder = SortOrder.FilenameAscending
(I believe this sets the default sort order.)

Changes to my code.

This query statement

Code: Select all

Everything.Query(queryString=search_statement, matchingOptions=Everything.QueryStringOptions.WholeWord, sortOrder=SortOrder.AccessDate)
is now this.

Code: Select all

Everything.Query(queryString=search_statement, matchingOptions=Everything.QueryStringOptions.WholeWord, sortOrder=Everything.SortOrder.AccessDateDescending)
(I needed to add the Everything import to get the SortOrder class to work.)

My code seems to be working correctly.

Thanks for the suggestions.
Post Reply