Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Open PDF via "run service" (Read 1494 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Open PDF via "run service"

Many years ago I got support here how to setup a key command to open a pdf that's inside the directory of the playing track.
That worked for many years, but now has stopped working somehow. As I didn't use the function for maybe a year or so I have no clue if that happened after a foobar update or an acrobat update. Im am currently on Foobar 1.6.14 32 bit on windows 10 32 bit.

That's how I did set up the path to the reader with the parameter to find the pdf-file, I have no clue why I have it set up like that, I just did what I was told to do :-)
"C:\Program Files\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" "$replace(%_path%,%_filename_ext%,)*.pdf"

The error I get now says "During opening of this file an error ocured. The syntax for the file name, the directory name or the volume name is wrong" (or something like that, I translated the German message)
I also have tried it without the underscores in front of "filename_ext" and "Path" as I don't understand why they are there but that didn't help.

Maybe some skilled persons notice at first sight what could be wrong.

Re: Open PDF via "run service"

Reply #1
Many years ago I got support here... I have no clue why I have it set up like that, I just did what I was told to do :-)
It would be helpful if you provide a link to the original discussion.

I also have tried it without the underscores in front of "filename_ext" and "Path" as I don't understand why they are there but that didn't help.
I don't know what's changed to cause your failure, or what your string substitution is intended to achieve (your original thread ought to provide a clue), but as a general point you should get to know what Title Formatting is all about (the core of FB2K customisation): https://wiki.hydrogenaud.io/index.php?title=Foobar2000:Title_Formatting_Reference#.25path.25

I don't know for sure, but I suspect the underscore prefix is optional.
It's your privilege to disagree, but that doesn't make you right and me wrong.


Re: Open PDF via "run service"

Reply #3
That worked for years and sometimes stopped to work...
Does the console output provide any clues?  Menu > View > Console might provide a view of the command being sent to the operating system and any error messages resulting.

What I want to archive is open the pdf in the music directory with a keystroke.
Yes, but how?  I guess I'll have to work it out for myself (thanks)...  So you are triggering an event on (eg) %path% = <some path>\<some music file>.mp3 and expect to open <some path>\<any name>.pdf?

I gather from that the $replace is supposed to extract <some path> from %path%.  As per:

People always forget $directory_path():

Quote
"C:\Program Files\Irfanview\i_view32.exe" "$directory_path(%path%)\*01.jpg"

...there is a text function specifically for extracting the directory from %path%.  From the wiki page for Title Formatting:

Quote
$directory_path(path)
Extracts directory path from the file path.

(For "file" read "string")

So instead of your
"C:\Program Files\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" "$replace(%_path%,%_filename_ext%,)*.pdf"
try
"C:\Program Files\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" "$directory_path(%path%)\*.pdf"

...and if that doesn't work try it with "*.pdf" instead of "\*.pdf".

I suspect if your original version stopped working then this won't work either, I don't think we've got to the bottom of the cause.  It could be something to do with drive handling: is your music now on a different drive than C: or perhaps you've moved FB2K?
It's your privilege to disagree, but that doesn't make you right and me wrong.

Re: Open PDF via "run service"

Reply #4
First thing I assumed was that your path to Adobe Reader was wrong. It automatically updates and at least here the exe is now called Acrobat.exe and its location is different. But that's not the only problem. The current version can't open "*.pdf". It doesn't search for matching files but just gives an access denied error as a file by that name does not exist.

Re: Open PDF via "run service"

Reply #5
Here's a substitute:
cmd.exe /C for %%i in '('"$directory_path(%path%)\*.pdf"')' do start "" "%%~i"

Enable "minimize" setting so that command prompt doesn't flash annoyingly. This opens all found PDF files in the directory with the associated program.

Re: Open PDF via "run service"

Reply #6
The current version can't open "*.pdf". It doesn't search for matching files but just gives an access denied error as a file by that name does not exist.
Thanks for taking this over!  So that's the smoking gun.  I presume this would have showed up in Console?

cmd.exe /C for %%i in '('"$directory_path(%path%)\*.pdf"')' do start "" "%%~i"
Excellent.  Much more robust.
It's your privilege to disagree, but that doesn't make you right and me wrong.

Re: Open PDF via "run service"

Reply #7
Thanks all so far. I will try these steps.
Btw the console doesn't show anything when I try it.

Re: Open PDF via "run service"

Reply #8
Here's a substitute:
cmd.exe /C for %%i in '('"$directory_path(%path%)\*.pdf"')' do start "" "%%~i"

Enable "minimize" setting so that command prompt doesn't flash annoyingly. This opens all found PDF files in the directory with the associated program.
OK, works like a charm.
Thank you very, very much!!

Re: Open PDF via "run service"

Reply #9
BTw here in Germany the exe is still called "AcroRd32" and is still at the same place. That was the first thing I checked.

Re: Open PDF via "run service"

Reply #10
Here's a substitute:
cmd.exe /C for %%i in '('"$directory_path(%path%)\*.pdf"')' do start "" "%%~i"

Enable "minimize" setting so that command prompt doesn't flash annoyingly. This opens all found PDF files in the directory with the associated program.

WOW THX.

Added command in my skin. Video:

https://www.youtube.com/@solomusica277

Then I validated the minimize box, and the dos window does not appear.

 

Re: Open PDF via "run service"

Reply #11
Here's a substitute:
cmd.exe /C for %%i in '('"$directory_path(%path%)\*.pdf"')' do start "" "%%~i"

Enable "minimize" setting so that command prompt doesn't flash annoyingly. This opens all found PDF files in the directory with the associated program.

WOW THX.

Added command in my skin. Video:

https://www.youtube.com/@solomusica277

Then I validated the minimize box, and the dos window does not appear.
Great music!