Did you miss your activation email?

• Monday January 30, 2023, 4:13 pm
• Proudly celebrating 15+ years online.
• Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.

### Author Topic: #filecontents FILEPATH -- how does it work?  (Read 17275 times)

#### Nod5

• Supporting Member
• Joined in 2006
• Posts: 1,156
##### #filecontents FILEPATH -- how does it work?
« on: March 02, 2009, 05:14 PM »
the new FARR 2.48.01 has added this:

#filecontents FILEPATH (can use %ALIASDIR%), to have the contents of the file dumped into the alias results when searching.

My first though that the FILEPATH should point to a textfile (e.g. C:\test\test.txt ) that includes paths to other files. Each such included path is then listed as a result in FARR when the alias runs. But that did not work when I tested it. So what exactly does it do?  An example of an exported alias using this would be useful here.

#### nitrix-ud

• Charter Member
• Joined in 2005
• Posts: 560
##### Re: #filecontents FILEPATH -- how does it work?
« Reply #1 on: March 03, 2009, 01:38 AM »
hi Nod5,

however just try to add that in front of your #filecontents command :

anything will do | #filecontents FILEPATH...

it seems that the "|" is needed to make it work

cheers, Nitrix

#### Nod5

• Supporting Member
• Joined in 2006
• Posts: 1,156
##### Re: #filecontents FILEPATH -- how does it work?
« Reply #2 on: March 03, 2009, 03:42 AM »
Aha, ok now I got it working.
Example: 1000>>>aoao>->test | #filecontents C:\test\a.txt
(and in a.txt put a filepath as a string )

It does not seem to work in companion with other alias specials:
1000>>>photo>->photo $$1 | dosearch +photo_modifier$$1 #filecontents C:\test\a.txt>+>^photo (.*)
Maybe it isn't supposed to work in such cases. But it would be cool if it did. I.e. if we got the results from the file at top and below it any and all matches from the search.

#### nitrix-ud

• Charter Member
• Joined in 2005
• Posts: 560
##### Re: #filecontents FILEPATH -- how does it work?
« Reply #3 on: March 03, 2009, 08:37 AM »
as i understant it, the idea of the #filecontents command is to "only" externalize the list of results you put inside the result box within a alias edit dialog to an external file
so that you can edit your alias or share it much more easily

#### Nod5

• Supporting Member
• Joined in 2006
• Posts: 1,156
##### Re: #filecontents FILEPATH -- how does it work?
« Reply #4 on: March 03, 2009, 10:06 AM »
huh?

#### nitrix-ud

• Charter Member
• Joined in 2005
• Posts: 560
##### Re: #filecontents FILEPATH -- how does it work?
« Reply #5 on: March 03, 2009, 10:38 AM »
sorry if i'm not clear enough

take a look at my tiny tutorial to see what i mean :
https://www.donationcoder.com/forum/index.php?topic=17270.0

#### Nod5

• Supporting Member
• Joined in 2006
• Posts: 1,156
##### Re: #filecontents FILEPATH -- how does it work?
« Reply #6 on: March 03, 2009, 03:33 PM »
Ok, got it now. Then it can't do what I was most hoping for. That is combine the results from the .txt (placed first in the results) AND the results from a FARR search (placed last).

I can see the use of it for other purposes though. But I'm not sure how it makes alias sharing easier... Before, you only needed to do an export and the copy+paste that. With #filecontents you both need to export and copy+paste AND copy the external .txt file.

#### mouser

• First Author
• Joined in 2005
• Posts: 40,860
##### Re: #filecontents FILEPATH -- how does it work?
« Reply #7 on: March 03, 2009, 03:46 PM »
That is combine the results from the .txt (placed first in the results) AND the results from a FARR search (placed last).

someone could make an fsubscript plugin to do this very easily i think.

#### ewemoa

• Honorary Member
• Joined in 2008
• Posts: 2,922
##### Re: #filecontents FILEPATH -- how does it work?
« Reply #8 on: March 04, 2009, 01:15 AM »
I'm not sure I'm following Nod5's idea very clearly.

Reflecting on the following bits from the perspective of a plugin implementation:

a textfile (e.g. C:\test\test.txt ) that includes paths to other files. Each such included path is then listed as a result in FARR when the alias runs.

That is combine the results from the .txt (placed first in the results) AND the results from a FARR search (placed last).

The first bit raises the question of how the plugin finds which file to work w/:

• via a special file extension?
• via a user variable setting made by the user?
• via a specific directory (or multiple directories) to look in?
• or some other means...

The second bit has me wondering about how to ensure that all items from the file (.txt or something else appropriate) appear before all other results.  Very large score inflation?

Any thoughts?

#### mouser

• First Author
• Joined in 2005
• Posts: 40,860
##### Re: #filecontents FILEPATH -- how does it work?
« Reply #9 on: March 04, 2009, 05:56 AM »
ewe,
to keep things simple you might simply:
1) let user specify a filename in the user variables where the result alias will be found
2) let user specify a score to be applied to all of the items, but then return the results such that farr can add its score to that score.

actually now that i type this out, perhaps this would be best implemented in core FARR functionality..

perhaps what i should do is make it so that if you type +ALIASNAME it will *add* the alias contents (including obeying a #filecontents) into the current search results (with their configured score), but *not* to the exclusion of other searching.  i think that would accomplish what is desired.
« Last Edit: March 04, 2009, 06:00 AM by mouser »

#### Nod5

• Supporting Member
• Joined in 2006
• Posts: 1,156
##### Re: #filecontents FILEPATH -- how does it work?
« Reply #10 on: November 19, 2017, 09:41 AM »
Holy necro thread revival!  But on topic I think.

I want to make a FARR alias that first runs an external script and thereafter displays results from that script as a list of files in the regular FARR search results window. Not as a html view.

Request: make the #filecontents virtual string compatible with other, preceding virtual strings and the ;;; command .

I'm thinking of a use case like this:
alias trigger:
zzz
results:
| dolaunch appcap C:\script.ahk ;;; #filecontents C:\list.txt

The alias would first run C:\script.ahk which does something and then outputs a newline separated list of filepaths to C:\list.txt . FARR thereafter moves on to the #filecontents command. Which reads list.txt as rows for the alias results box , which are then displayed in the FARR search results window.

Alternative request to achieve the same end result:
Add a new virtual launch string, for example "showfilelist FILENAME", that can be used to import a linebreak separated plaintext list of files to display as search results . Must also be compatible with ;;; and other, preceding virtual strings.

Edit:
I realized this two alias workaround is a way to do it. But a one alias method would be less messy.
first alias:
zzz
results:
| dolaunch appcap C:\script.ahk ;;; restartsearch zzx
second alias:
zzx
results:
| #filecontents C:\list.txt
« Last Edit: November 19, 2017, 10:03 AM by Nod5 »

#### mouser

• First Author
• Joined in 2005
• Posts: 40,860
##### Re: #filecontents FILEPATH -- how does it work?
« Reply #11 on: November 19, 2017, 11:18 AM »
I will implement this.. However I believe there is already a virtual command in FARR that launches a command script and grabs the output to show as a result list, which is basically what you are interested in (though in your case your want to have a script that saves to a file and then have farr read that file as a filecontents).

#### Nod5

• Supporting Member
• Joined in 2006
• Posts: 1,156
##### Re: #filecontents FILEPATH -- how does it work?
« Reply #12 on: November 19, 2017, 12:49 PM »
Great to hear. I think virtual commands that ease input/output of this sort can be quite useful, since they enable users to do plugin-ish things with some well crafted aliases and simple Autohotkey scripting (simple compared to learning to code FARR plugins).

I believe there is already a virtual command in FARR that launches a command script and grabs the output to show as a result list
-mouser

I don't see anything on this list would do that
https://www.donation...l_launch_strings.htm

Grabbing output from some external process can also be useful. Though when using Autohotkey it is easier/shorter to read from a plaintext file and/or the clipboard.
« Last Edit: November 19, 2017, 12:56 PM by Nod5 »

#### mouser

• First Author
• Joined in 2005
• Posts: 40,860
##### Re: #filecontents FILEPATH -- how does it work?
« Reply #13 on: November 19, 2017, 01:12 PM »
Maybe when I thought of that command I was thinking about Launchbar Commander.. The overlap in functionality is large enough that I often confuse myself between the two of them.. I will check and add the functionality if it doesn't exist yet..

#### mouser

• First Author
• Joined in 2005
• Posts: 40,860
##### Re: #filecontents FILEPATH -- how does it work?
« Reply #14 on: February 04, 2019, 04:40 AM »
I'm embarassed I never got back to this thread; someone just asked for the same functionality in the #donationcoder chat and I, once again, thought it already existed when it doesn't quite.
I will try to get this implemented this weekend, with a single command that will run a script/exe and grab its output as a list of results to show.

#### ertwro

• Participant
• Joined in 2019
• Posts: 3
##### Re: #filecontents FILEPATH -- how does it work?
« Reply #15 on: February 04, 2019, 04:54 AM »
I just looked for software similar to dmenu or rofi from Linux but on Windows and out of all the alternative FARR is by far the best. The main thing I was missing was dmenu's greatest strength: receiving stdin from a script and displaying the output as a list in the FARR window and if possible using that to run scripts (stdout). Something like the following gif:

https://media.giphy....6yl62jpYfa/giphy.gif

When I found the Special/Virtual launch strings/commands and #filecontents offered this capability I got super excited, but when I heard it was gonna get implemented as a new function I threw my hands up and screamed "yes!". I'll stay super tuned.
« Last Edit: February 06, 2019, 01:08 PM by ertwro »

#### Nod5

• Supporting Member
• Joined in 2006
• Posts: 1,156
##### Re: #filecontents FILEPATH -- how does it work?
« Reply #16 on: February 06, 2019, 04:34 AM »
I will try to get this implemented this weekend, with a single command that will run a script/exe and grab its output as a list of results to show.
-mouser

Nice! Though I think it would be more versatile if #filecontents was made compatible with ;;; and multiple virtual strings on a results line in the alias setup. That way we could do
example | dolaunch appcap C:\program.exe ;;; #filecontents C:\text.txt
where FARR waits for the first command (run a program that outputs something to text.txt) to finish before processing the #filecontents command which imports each line in text.txt as a line to show in FARR's results window.

More versatile since the stdout from many tools isn't in a format compatible with FARR's #filecontents command. If the above method was added then we could work around that by inserting a step that first reformats the text.txt to be compatible with the #filecontents command.
example 2 | dolaunch appcap C:\program.exe ;;; appcap C:\script.ahk ;;; #filecontents C:\text.txt

BTW a small bug with #filecontents:
If a line in the text.txt file isn't an existing filepath, but instead some text string, it will erroneously reuse the icon from the previous results line. For example if text.txt contains
C:\image.jpg
some text message
C:\image2.jpg
then all three results lines will show the icon for jpg images. It would be better if the middle results line didn't show any icon at all.

#### ertwro

• Participant
• Joined in 2019
• Posts: 3
##### Re: #filecontents FILEPATH -- how does it work?
« Reply #17 on: February 06, 2019, 01:29 PM »
Yeah, I've been reading and trying some stuff but as you told me there's no easy way to do what I want just with #filecontents and launch string/commands. Tried to circumvent this by using pipes but found out that Windows doesn't use fifo files per se and uses sockets in the form of \\.pipe\whatever.

#### mouser

• First Author
• Joined in 2005
• Posts: 40,860
##### Re: #filecontents FILEPATH -- how does it work?
« Reply #18 on: February 10, 2019, 04:16 PM »
I am implementing both "appcapresults" function which will pull results directly from a script, but also Nod5's request for a separate command that says to pull results from a text file, in a way that can be chained together with other virtual launch strings.

Does anyone have a script/executable that I can use to test the new appcapresults function?
So I need an executable that produces results for FARR to display (in normal alias result format, with option icon and nice label, etc.).

BTW a small bug with #filecontents:  If a line in the text.txt file isn't an existing filepath, but instead some text string, it will erroneously reuse the icon from the previous results line. For example if text.txt contains

let me try to fix that.
« Last Edit: February 11, 2019, 07:37 AM by mouser »

#### mouser

• First Author
• Joined in 2005
• Posts: 40,860
##### Re: #filecontents FILEPATH -- how does it work?
« Reply #19 on: February 10, 2019, 08:17 PM »
BTW a small bug with #filecontents:  If a line in the text.txt file isn't an existing filepath, but instead some text string, it will erroneously reuse the icon from the previous results line. For example if text.txt contains
Ok, I've fixed this -- it was a more general problem with using previous icon when one shouldn't be used at all, and was probably the cause of an occasional report that a random icon was being used when there was only one result and it should not have an icon.
« Last Edit: February 10, 2019, 08:22 PM by mouser »

#### mouser

• First Author
• Joined in 2005
• Posts: 40,860
##### Re: #filecontents FILEPATH -- how does it work?
« Reply #20 on: February 11, 2019, 08:00 AM »
Ok I believe I have it working in a beta.  Message me for download link to beta.
New command "appcapresults" to run a script/executable and capture its output to display as a list of results (should be able to use all the normal options for display nice labels, custom icons, etc.).
New command "fileresults" which should behave just like the unusual "#filecontents" directive, except that it can be used now in the same way that the other commands can be, so it can be chained together with other commands.
Bug fixed where a result had the icon of the item before it if it should otherwise have had no icon.

#### mouser

• First Author
• Joined in 2005
• Posts: 40,860
##### Re: #filecontents FILEPATH -- how does it work?
« Reply #21 on: February 13, 2019, 08:22 AM »
Beta for testing here:
• Setup version: here
• Portable version: zip.

The new commands are "appcapresults" and "fileresults".

#### ertwro

• Participant
• Joined in 2019
• Posts: 3
##### Re: #filecontents FILEPATH -- how does it work?
« Reply #22 on: February 13, 2019, 09:37 AM »
I've not had the opportunity of testing it fully but so far is working super well with batch, vbs and even my bash scripts . I can't wait to try so many things!

#### mouser

• First Author
• Joined in 2005
• Posts: 40,860
##### Re: #filecontents FILEPATH -- how does it work?
« Reply #23 on: February 13, 2019, 09:39 AM »
Great

• First Author