Translate file name in mapped drive to unc path filename

7 次查看(过去 30 天)
Hello! Which function translates file name given in mapped drive path to file name given in UNC path? For example: z:/abc/test.m to //nettapp1/abc/test.m Thanks in advance!!
  3 个评论
L
L 2022-6-28
Thanks, but I know there is a Matlab function which does this automatically. I prefer to use it.
dpb
dpb 2022-6-28
" I know there is a Matlab function which does this automatically..."
I don't believe there is any such thing in base MATLAB. Maybe somebody has posted something on FEX, but unless there's a java method (and I don't know that there is), capturing the output from NET USE is the ticket for a Windows box.

请先登录,再进行评论。

回答(1 个)

Jan
Jan 2022-6-29
No, there is no Matlab command to perform this automatically.
net use sovles this and WMIC can help also:
[status, out] = system('wmic path win32_mappedlogicaldisk get deviceid, providername');
List = strsplit(out, '\n');
Line = List{startsWith(List, 'Z:')};
UNC = strtrim(Line(3:end));
Or parse the output of the PowerShell command:
Get-WmiObject Win32_NetworkConnection | where -Property 'LocalName' -eq 'Z:' | ft "RemoteName","LocalName" -A

类别

Help CenterFile Exchange 中查找有关 Search Path 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by