Page 1 of 2

script to execute specific search

Posted: 09 Jul 2008 17:00
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.

Posted: 09 Jul 2008 23:43
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

Posted: 10 Jul 2008 02:56
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:

Posted: 10 Jul 2008 05:21
by serendipity
Yup, some of my tasks need search templates too. So automating them with scripts would be cool.

Posted: 10 Jul 2008 13:48
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)

Posted: 10 Jul 2008 17:18
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.

Posted: 10 Jul 2008 17:32
by luckman212
i think the way Jacky outlined it is perfect, that would suit my needs exactly. :)

Posted: 10 Jul 2008 18:12
by TheQwerty
It sounds good to me as well, but I think "LoadSearch" might be a better name for the command. :wink:

Posted: 10 Jul 2008 18:25
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?

Posted: 10 Jul 2008 18:26
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.

Posted: 10 Jul 2008 20:06
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.

Posted: 10 Jul 2008 20:26
by jacky
Well then, just call it LoadSearchTemplate and there's no problem! ;)

Posted: 10 Jul 2008 20:28
by serendipity
jacky wrote:Well then, just call it LoadSearchTemplate and there's no problem! ;)
Yup, no problem there.

Posted: 10 Jul 2008 20:45
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.

Posted: 10 Jul 2008 22:26
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...