-
Notifications
You must be signed in to change notification settings - Fork 81
Show in Directory does not work for certain file-names. #1069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It can be the length, or escaping. Using these windows utilities is generally PITA. There was already a PR that tried to help with opening paths with commas in them (#800). But maybe there are issues with other characters too. The snippet that handles this is here: Lines 1031 to 1047 in 0b65802
You can try playing around with it. |
Even with long paths enabled From what i know, your only option here is to either move the files to |
This works: local ffi = require("ffi")
ffi.cdef[[
typedef long HRESULT;
typedef unsigned long DWORD;
typedef struct _ITEMIDLIST {
unsigned short cb;
unsigned char abID[1];
} ITEMIDLIST, *LPITEMIDLIST, *LPCITEMIDLIST;
HRESULT SHOpenFolderAndSelectItems(LPCITEMIDLIST pidlFolder, unsigned int cidl, LPCITEMIDLIST* apidl, DWORD dwFlags);
HRESULT SHParseDisplayName(const wchar_t* pszName, void* pbc, LPITEMIDLIST* ppidl, DWORD sfgaoIn, DWORD* psfgaoOut);
void CoTaskMemFree(void* pv);
int MultiByteToWideChar(unsigned int CodePage, DWORD dwFlags, const char* lpMultiByteStr, int cbMultiByte, wchar_t* lpWideCharStr, int cchWideChar);
]]
local CP_UTF8 = 65001
local shell = ffi.load("Shell32.dll")
local ole32 = ffi.load("Ole32.dll")
local function open_folder_and_select_item(utf8_path)
local utf16_len = ffi.C.MultiByteToWideChar(CP_UTF8, 0, utf8_path, -1, nil, 0)
if utf16_len == 0 then
return
end
local utf16_path = ffi.new("wchar_t[?]", utf16_len)
if ffi.C.MultiByteToWideChar(CP_UTF8, 0, utf8_path, -1, utf16_path, utf16_len) == 0 then
return
end
local pidl = ffi.new("LPITEMIDLIST[1]")
if shell.SHParseDisplayName(utf16_path, nil, pidl, 0, nil) ~= 0 or pidl[0] == nil then
return
end
shell.SHOpenFolderAndSelectItems(pidl[0], 0, nil, 0)
ole32.CoTaskMemFree(pidl[0])
end
mp.add_key_binding(nil, "open-in-explorer", function()
local path = mp.get_property("path")
if path then
-- mpv adds '\\?\' prefix when long paths aren't enabled in Windows
if path:sub(1, 4) == "\\\\?\\" then
path = path:sub(5)
end
if path:match("^%a:[/\\]") and not path:match("^%a[%a%d-_]+://") then
open_folder_and_select_item(path:gsub("/", "\\"))
else
mp.osd_message("Invalid path: " .. path)
end
end
end)
On top of that, if it's still open it will focus the same window rather than always opening a new one like the Surely all Windows builds use LuaJIT :^) |
MPV Version: v0.38.0-743-gad7976c3
Script Version: 5.7.0
Platform: Windows 10 22H2
I'm using this in my input.conf
MBTN_MID_DBL script-binding uosc/show-in-directory
When I initiate a double middle-click it opens This PC instead of opening the directory where the file is located.
Folder Name:
Even Given the Worthless Appraiser Class, I'm Actually the Strongest
File Name:
[ToonsHub] Even Given the Worthless Appraiser Class Im Actually the Strongest S01E07 1080p B-Global WEB-DL AAC2.0 H.264 (Fuguushoku [Kanteishi] ga Jitsu wa Saikyou Datta - Naraku de Kitaeta Saikyou no [Shingan] de Musou Suru, Multi-Subs)
Directory Path of the File:
K:\Media\Anime\Even Given the Worthless Appraiser Class, I'm Actually the Strongest\[ToonsHub] Even Given the Worthless Appraiser Class Im Actually the Strongest S01E07 1080p B-Global WEB-DL AAC2.0 H.264 (Fuguushoku [Kanteishi] ga Jitsu wa Saikyou Datta - Naraku de Kitaeta Saikyou no [Shingan] de Musou Suru, Multi-Subs).mkv
The only reason why I can think it might not be working is because perhaps the filename is too long.
The text was updated successfully, but these errors were encountered: