script to execute specific search

Discuss and share scripts and script files...
luckman212
Posts: 9
Joined: 09 Jul 2008 16:58

script to execute specific search

Post by luckman212 »

hello,
i want to use XY to store and later execute various special searches that I have designed (for example, searching specific folders for files that have their "index" bit not set). I have figured out that you can use the Search Templates feature to store and recall searches but I would like to be able to make Desktop shortcuts to directly launch XY and run these searches via scripting.

is this possible?? please can someone offer some guidance. thank you.

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Post by serendipity »

Hi and Welcome to XYplorer,

Some basic searches can be done from catalog. Standard, Boolean and RegExp are suported. So you can store your search patterns in catalog for the time being. More advanced features like size, date, exclude folder are not possible from catalog. I too am hoping those things will be part of scripting soon.
Read Wiki about "Running a search from catalog":
http://88.191.26.34/XYwiki/index.php/Ca ... ame_Search

luckman212
Posts: 9
Joined: 09 Jul 2008 16:58

Post by luckman212 »

i hope so too. Maybe this will be added to a future version? at least the ability to run Search Templates via script would be nice. :wink:

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Post by serendipity »

Yup, some of my tasks need search templates too. So automating them with scripts would be cool.

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

Yes, this has been talked about before - and I'd be interested as well - and I believe it is somewhere on Don's list. So it'll come, eventually.

If we want to talk about this, here's what I would suggest:

loadtemplate <template name>, <options>
With
<template name>
the name of the template to load

<options>
A combo of:
r: Run search
l: load Location
e: load Excluded folders
Default being "rl"


Now there could also be a command find, but that's a whole lot more complicated to come up with, and unless I'm wrong a search template is only one INI file anyway...

In fact, because it is an INI file, you could have your script to write a default INI file (which will be even a lot easier once command write is implemented) and then use setkey to adjust some values according to whatever you want (eg. ask user (input) for keywords, etc)
Proud XYplorer Fanatic

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Post by serendipity »

The "Loadtemplate" example is ideal, but i guess apart from options there can be also be some sort of index to the ini keys which user can refer to and set. The key set by user is changed and rest is default.
But on the other hand user can also use set and getkey commands to access them.
I guess, the first method (where syntax for each search criteria will be set by Don) will be a lot easier for most users.

luckman212
Posts: 9
Joined: 09 Jul 2008 16:58

Post by luckman212 »

i think the way Jacky outlined it is perfect, that would suit my needs exactly. :)

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Post by TheQwerty »

It sounds good to me as well, but I think "LoadSearch" might be a better name for the command. :wink:

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

TheQwerty wrote:It sounds good to me as well, but I think "LoadSearch" might be a better name for the command. :wink:
Well, I feel loadtemplate is more accurate since it loads a template, but the search needs to be run.
Also, for consistency sake, the button that already exists on the Search Templates window reads "Load Template", and since it would do the exact same it make sense to use the same caption, doesn't it?
Proud XYplorer Fanatic

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Post by j_c_hallgren »

TheQwerty wrote:It sounds good to me as well, but I think "LoadSearch" might be a better name for the command. :wink:
Well, given that button in that dialog panel says "Load template", and as there aren't any other templates now, I think jacky's name makes more sense.
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Post by TheQwerty »

jacky wrote:Also, for consistency sake, the button that already exists on the Search Templates window reads "Load Template", and since it would do the exact same it make sense to use the same caption, doesn't it?
Not really. In that instance it's already established that the button is being applied to Search Templates, as the dialog's title and header both make it abundantly clear.
j_c_hallgren wrote:...and as there aren't any other templates now, I think jacky's name makes more sense.
However, if in the future there are other templates (perhaps for Reports or something), then "LoadTemplate" will be an extremely unfortunate name and will need to be deprecated. Why not plan ahead and avoid this complication by using a more descriptive name?


Furthermore, a user who is writing a script may not be familiar with Search Templates and will likely skip over "LoadTemplate" in a list of commands, because it is ambiguous to the type of template loaded and provides no clue that it's related to their goal.

While, LoadTemplate may perfectly describe what the function does, I believe most users will be using such a command to execute a search, and it doesn't communicate that well.


LoadSearch may not be a good name either, but it removes some of the ambiguity and avoids a problem if there is ever another Template.

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

Well then, just call it LoadSearchTemplate and there's no problem! ;)
Proud XYplorer Fanatic

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Post by serendipity »

jacky wrote:Well then, just call it LoadSearchTemplate and there's no problem! ;)
Yup, no problem there.

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Post by j_c_hallgren »

Or make the type of template the first required parameter, maybe? This would reduce the number of total commands yet still allow for other types if there ever was more than search.
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

j_c_hallgren wrote:Or make the type of template the first required parameter, maybe? This would reduce the number of total commands yet still allow for other types if there ever was more than search.
No I think that would be a bad idea, since we have no idea if there will be other templates, what they would be (like) and how they'd be used.

The options here only apply to search templates. And, for example, for reports it could only be a parameter to the "makereport" command, to specify which template to use...
Proud XYplorer Fanatic

Post Reply