If VLC is running, playing a movie at file path X, is there any way I can know what file path X is from a Bash script? (For simplicity's sake we can assume that only one instance of VLC is running.)

Update: I now know this can be done using the following methods. Are there other ways, perhaps a way of asking VLC directly?

  1. AppleScript (macOS only)
  2. lsof (All Unix)

2 Answers 2


That's an easy one

osascript -e 'tell application "VLC" to get path of current item'

That returns the path to the currently playing movie. If you want more I suggest you select "Open Dictionary.." in the File menu of "Script Editor", select VLC and have a good look. Then do man osascript on the command line for the man page of osascript.


Unix & Linux suggests a generic way using lsof:

lsof -wc VLC | awk '$4~"[0-9]r" && $5=="REG"' | grep -o '/.*'

This method includes a couple of system files too, but these can be easily removed with grep.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .