Skip to content

Instantly share code, notes, and snippets.

@Sneakpeakcss
Last active November 21, 2023 15:14
Show Gist options
  • Save Sneakpeakcss/05a97d509b8be67a6f11400b0bee54ab to your computer and use it in GitHub Desktop.
Save Sneakpeakcss/05a97d509b8be67a6f11400b0bee54ab to your computer and use it in GitHub Desktop.
mpv player script to open directory and select currently playing file (Windows).
-- open-in-explorer.lua
mp.add_key_binding(nil, "open-in-explorer", function()
local path = mp.get_property("path")
if path ~= nil and not path:match("^%a[%a%d-_]+://") then
path = string.gsub(path, "/", "\\")
mp.command_native({
name = "subprocess",
playback_only = false,
args = { 'explorer', '/select,', path .. ' ' },
})
else
mp.osd_message("Invalid path: " .. (path or "No path provided"))
end
end)
@Sneakpeakcss
Copy link
Author

Sneakpeakcss commented Nov 20, 2023

Okay, main version seems to now work in every single case, so there's again no need to use the above PowerShell solution.

@po5
Copy link

po5 commented Nov 21, 2023

Was the fix just appending a space to the path? Please submit a PR with uosc since you have a setup to reproduce this. 🙏

@Sneakpeakcss
Copy link
Author

Yea, a trailing space was all it takes to fix this. I've submited the mentioned PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment