1

I am working on a module for FOOBAR2K, a music player. So that it can be controlled and used from the terminal, For example Get-FooBar -status:

Name                     Value  
----                     -----  
Artist                   Antonio Carlos Jobim  
Song                     Amparo  
Album                    Stone Flower  
Current Time             0:09  
Total                    Time 3:42  
Path                     C:\Music Library\Antonio Carlos Jobim - Stone Flower\Amparo.flac

I have covered quite a bit of ground. One functionality I need is to add\append to the currently playing playing files.

I can take some songs and create a new "currently playing" list just fine:

Get-ChildItem -path ".\Antonio Carlos Jobim - Stone Flower" -Exclude *sabia*,*amp* | Set-FooBar

But I sometimes need a way to append to the "Currently Playing List". I did some investigation, in File Explorer, If I right click a file that Foobar is set to handle, there are two entries from Foobar:

  • "Play in Foobar"
  • "Enqueue in Foobar"

Using Enqueue in Foobar on a selection of audio file in Explorer will add those files to FOOBAR's "Currently Playing" list.

I am interested in invoking this verb from PowerShell. I did some searching and experimenting:

This article Use PowerShell to Work with Windows Explorer - Scripting Blog I was able to find verbs for folders but passing Files in the same way, returns errors:

$Shell = New-Object -ComObject 'Shell.Application'
$Shell.NameSpace('C:\Music Library\Antonio Carlos Jobim - Stone Flower\Amparo.flac').Self.Verbs()

Error:

OperationStopped:  
Line |  
2 | $Shell.NameSpace('C:\Music Library\Antonio Carlos Jobim - Stone...
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
| Error HRESULT E_FAIL has been returned from a call to a COM component.

I ran into similar issues with answers I found on StackOverflow as well.

Thanks for any help.

  • 1
    See if [this answer](https://stackoverflow.com/a/68930448/45375) helps. If so, we can close this one as a duplicate. – mklement0 Feb 26 '23 at 22:27
  • 1
    @mklement0 hey that worked for me, `[System.Diagnostics.ProcessStartInfo] @{ FileName = 'foo.mp3' }| % verbs` which returns `Enqueue`, `open` and `play`. Exactly what I needed. Thanks so much! – hellen_dorandt89 Feb 27 '23 at 11:44

1 Answers1

1

You're on the right track, but you have to use the shell.Namespace() method to obtain the folder that contains the file and then use the folder.ParseName() method to obtain the FolderItem for the file. Its .Verbs() method should return valid verbs for the file.

Unable to copy your file path while I'm trying to answer for my phone so we'll flesh this answer out when I get home to my computer.

mklement0
  • 382,024
  • 64
  • 607
  • 775
Keith Miller
  • 702
  • 5
  • 13
  • Hey thanks for this, I was not able to get it to work with the application I had in mind but it works for other apllications oddly enough. I will keep this for prosperity though. Thaks allot. – hellen_dorandt89 Feb 27 '23 at 11:46