ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Find And Run Robot

FARR alias for choosing program based on file extension

(1/4) > >>

wjamoe:
Sometimes you don't want to start the default program for a certain file extension.

With the aliases below, you can pass the file name to start a program which you can select from your user defined menu.

Use it as follows:

First search and find the file using farr's search field or directory traversal.

Then select the file multiple times [Cursor Down] and then [Cursor Right] to display the file name in the farr search box.

Then press <dot>

Then select the program you want to run it with F1..F9, or use the [Cursor] keys.

To shorten the list of menu items you can enter a string after the dot,  then only lines matching the string and the file extension.




jump to latest version  https://www.donationcoder.com/forum/index.php?topic=41913.msg394054#msg394054


Have fun :Thmbsup:

skajfes:
Hi, I love this  :Thmbsup: . It's simple and effective.
However, I've modified it a bit to fit my needs better.
First I've changed the regex to (.+\.(.{3,4}))\s?(.*)$, and I've changed the result filter to $$2 $$3
This ignores the trailing space when you expand the filename so you don't have to backspace it after expanding the filename. It also allows to further filter the menu by typing in the tool you want. (ie. index.html opera)
This also simplifies the result list a bit, as you can just write $$1 everywhere for the full filename instead of $$1.$$2. Also it matches both 3 and 4 character extensions.
I like having the default program in the first place so I can just run it by pressing enter. I've found that just running the file directly has the best results for me, also running a program with just giving the name (see notepad example below), and without cmd.exe or shellexec


--- ---run default program for file: $$1 | "$$1"
notepad txt ahk bat ini ion pdf | C:\Program Files (x86)\Notepad++\notepad++.exe "$$1"

mouser:
I'm not 100% following what's going on here -- which wouldn't be the first time I don't understand my own program :)

However i will just mention one thing, in FARR there is a help page under Advanced Use / Using Alias Action Keywords:


--- Code: Text ---A new feature with FARR version 2 is the ability to specify alias names in your search string using the + prefix (just like keyword modifiers). When an alias name is specified in this way, anywhere on the search string, it does not effect search, but it will cause the alias results to be displayed AFTER the result file is selected, with the selected file name as argument $$1 in the alias. In this way, you can perform a normal file/folder search and then launch a specific alias command with that file/folder as an ARGUMENT. For example, you could create an alias named hexeditwhose result contents are:C:\Program Files\HexEditors\HexEdit.exe "$$1" Now you can type in your search (where mydocsearch is something like "C:\Users\myfile.txt"):mydocsearch +hexedit As you type mydocsearch words, FARR will let you search for files as normal.After you choose the result, instead of launching the result file, you will be presented withC:\Program Files\HexEditors\HexEdit.exe "SELECTEDFILE"Which you can then launch.  NOTE:You can use the same keyword for both alias names and search/scoring keyword modifiers.
This is specifically to let you use +keyword to open files that you have found using a non-default program.

The key thing here is that you define an alias as normal, using $$1 for the file to be opened, but then instead of triggering the alias normally by typing its name first, you use +aliasname in the search.

wjamoe:
@skajfes, thanks for the optimisation  :Thmbsup:
I'll remove all shellex and cmd.exe's, they were needed in my very old version of farr, my bad  :-[, today I upgraded to v2.226.01 and assumed they were still needed.

I had to look up your PCRE :  (.+\.(.{3,4}))\s?(.*)$

$$1 contains file name including file name extension.
$$2 contains file name extension maximum length of 4 characters.
$$3 contains optionally for longer extensions 5th char and more followed by optional white space and optional characters that may contain more white space and dots.

----
I'm also working on a version where the alias
 
* opens websites e.g. donationcoder.com without http:// prefix, but instead based on domain .com/.net/.org/.nl/.uk/.de/.be,
* opens files like svg in a browser of your choice using file:///,
* tags a file or url (grouping). Tagging is done by adding  tag at the end of the path\file.txt.tag (object oriented method notation). It
 uses separate files for each tag. These files are created dynamically. I use farr's #filecontents tag_file to retrieve the list of tagged files
For tagging I still need something like $$1.$$2 because I must be able to remove the temporary added extension tag =$$2 from the file name =$$1 before using it

The regex then becomes ((.+)\.(\S*))\s(.*)$

$$1 contains file name including extension
$$2 contains file name without extension and without trailing dot
$$3 contains extension without the dot (any length)
$$4 contains white space followed by any character, can be used as optional parameter in the program call if so required.

The farr (extension) alias filter thus becomes $$3

With this alias just add an entry to the farr alias results
     program name file extensions it can open followed by '|' the full path to the program and "$$1" in double quotes because file name can contain spaces

There are still some challenges (like searching within the list of tagged files), I'll send an update soonish. 8)

@mouser, in the hexedit example the user needs to know beforehand that he wants to edit the file in hex mode.
After searching and selecting a file from the farr results With the above alias you can choose any program (from the alias menu) including the default program for the file.
My alias is more similar to

* windows right click open-with which uses file associations in the windows registry wikipedia on file associations
* NANY2012 extension warlock
* total commander openfiletc.exe
* drag & drop on an exe-icon on desktop using your mouse
* drag & drop on farr tool bar menu items using your mouse
With the above alias it is now fully integrated in FARR and can be performed without lifting your hands from the keyboard.
One additional advantage the program list will not change when some program hogs some or all file associations.

skajfes:
I had to look up your PCRE :  (.+\.(.{3,4}))\s?(.*)$

$$1 contains file name including file name extension.
$$2 contains file name extension maximum length of 4 characters.
$$3 contains optionally for longer extensions 5th char and more followed by optional white space and optional characters that may contain more white space and dots.

-wjamoe (November 14, 2015, 04:56 PM)
--- End quote ---

Just to clarify:
$$2 contains file extension of 3 or 4 characters. It would probably be better if I set it like \S+ instead of .{3,4} to match any length of characters that has at least one character.
$$3 contains anything else that might be typed after the filename - this is used for additional filtering of the menu.


@mouser, in the hexedit example the user needs to know beforehand that he wants to edit the file in hex mode.
-wjamoe (November 14, 2015, 04:56 PM)
--- End quote ---
This is not quite true. You can search for files like you do normally, ie. start typing part of the filename. And when you see the desired file in the list you add +hexedit to the end of the search string. If you have only one result in the result list it will change to the alias text, ie: Edit <filename> with hexeditor. If you launch it it will open in hexeditor. However if you have multiple files in the result list, when you launch any of them it will open in hexeditor, however, the result list will not change.

Navigation

[0] Message Index

[#] Next page

Go to full version