Using the Python 3 Everything SDK wrapper
-
- Posts: 11
- Joined: Sat Aug 05, 2023 5:48 pm
Using the Python 3 Everything SDK wrapper
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?
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?
Re: Using the Python 3 Everything SDK wrapper
Everything 1.5 will have support for accessing filters.
For now, please manually include the following in your search:
Audio:
Compressed:
Document:
Executable:
Folder:
Picture:
Video:
To get filenames with highlighted search terms, please see Everything_GetResultHighlightedFileName
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
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
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
Code: Select all
ext:bat;cmd;exe;msi;msp;msu;ps1;scr
Code: Select all
folder:
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
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
-
- Posts: 11
- Joined: Sat Aug 05, 2023 5:48 pm
Re: Using the Python 3 Everything SDK wrapper
This is my query statement.
How do I add a sort to the query? I've tried these and none of them work.
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?
Code: Select all
Everything.Query(queryString=search_statement, maxResults=max_num_results)
Code: Select all
sortOrder=SortOrder.AccessDate
sortOrder="SortOrder.AccessDate"
sortOrder=AccessDate
sortOrder="AccessDate"
sortOrder=23
sortOrder="23"
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?
-
- Posts: 11
- Joined: Sat Aug 05, 2023 5:48 pm
Re: Using the Python 3 Everything SDK wrapper
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)
Re: Using the Python 3 Everything SDK wrapper
For Date Accessed, please try the following:
For Date Modified, please try the following:
For Date Created, please try the following:
Please try the following change to Everything.py:
However, if sorting by a fast sort, the sort is done first. (for example, name, path, size or date modified)
Fast sorts are instant.
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)
They don't appear to be defined in this third party py project.Also, how do I indicate ascending or descending?
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
Everything will do the sort after finding your results.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?
However, if sorting by a fast sort, the sort is done first. (for example, name, path, size or date modified)
Fast sorts are instant.
-
- Posts: 11
- Joined: Sat Aug 05, 2023 5:48 pm
Re: Using the Python 3 Everything SDK wrapper
I did the following.
Changes to Everything.py:
Modified the SortOrder class per your suggestion.
Changed this line in the Query class
to this.
(I believe this sets the default sort order.)
Changes to my code.
This query statement
is now this.
(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.
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
Code: Select all
sortOrder: SortOrder = SortOrder.FilenameAscending
Changes to my code.
This query statement
Code: Select all
Everything.Query(queryString=search_statement, matchingOptions=Everything.QueryStringOptions.WholeWord, sortOrder=SortOrder.AccessDate)
Code: Select all
Everything.Query(queryString=search_statement, matchingOptions=Everything.QueryStringOptions.WholeWord, sortOrder=Everything.SortOrder.AccessDateDescending)
My code seems to be working correctly.
Thanks for the suggestions.