Use this to avoid extraction and exclude the extension:
@nolocalizefiles
"http://www.google.com/search?q={o|noext}"
Use this to avoid extraction and exclude the extension:
@nolocalizefiles
"http://www.google.com/search?q={o|noext}"
Thanks.
After using above code (see Kundal) some time I found out that it cuts everything after a "&" in filenames.
Which syntax is needed to simply search for a filename incl. all kind of chars (but of course excluding extension)?
You'd need a script to modify the file name to use the appropriate encoding for a Google URL.
e.g. replace & with %26
JScript has a function for URL-encoding things which may do everything, but it might depend on what Google expects.
This seems to work fine with google.com:
Google Search (JScript script function button)
function OnClick(data) {
data.func.command.ClearFiles();
var objEnum = new Enumerator(data.func.sourcetab.selected);
while (!objEnum.atEnd()) {
var item = objEnum.item().name_stem; objEnum.moveNext();
var replacePlus = item.replace(/\+/g,"%%2B")
var replaceSpace = replacePlus.replace(/ /g,"+")
var search = replaceSpace.replace(/&/g,"%%26");
data.func.command.RunCommand("http://www.google.com/search?q=" + search);
}
}
Modifying Kundal's script slightly, JScript's encodeURIComponent covers a few more cases ( , / ? : @ & = + $ # although not all are possible in filenames to start with of course).
(The "replace" line is because it needs to double the % characters before running the command.)
function OnClick(data) {
data.func.command.ClearFiles();
var objEnum = new Enumerator(data.func.sourcetab.selected);
while (!objEnum.atEnd()) {
var item = objEnum.item().name_stem; objEnum.moveNext();
var encoded = encodeURIComponent(item);
var search = encoded.replace(/%/g,"%%");
data.func.command.RunCommand("http://www.google.com/search?q=" + search);
}
}
Nice, I tried encodeURI which didn't work.
That a what I was thinking of as well. I stumbled on the other one while searching for the first one's exact name, which was lucky.
I never would be able to script such things, so thank you both!
I used this with Docuwiki so now I can search anything in my documentary videos with one click. Thanks a ton guys!
I added it to the context menu but these pop up:
Set the button to Script mode, and then JScript as the language.
How do I set JScript as the language?
Ah, if it's in a context menu item, add a new line at the top, above the function OnClick...
line with this:
@script jscript
Splendid. thanks
You can do this more easily, and without scripting, in the new beta: Directory Opus 12.23.2 (Beta)
https://www.google.com/search?q={file|urlencode}
And how to search w/o extension?
{file|noext|urlencode}
should work