Jump to content

Shared Drive Network Path - OS X to Windows


Recommended Posts

Posted

There was a post from a while back that worked for me until a few months ago. We had a new shared drive installed and the old Alfred workflow doesn't work anymore.

 

This was the old code:

----

path = "{query}"
unc = ""
 
if (path.start_with?('smb:'))
# smb://NetworkDrive.corp.YYYY.com/Files/Folder/Folder
 
parts = path.split('//') # ["smb:", "NetworkDrive.corp.YYYY.com/Files/Folder/Folder"]
path_parts = parts[1].split('/') # ["NetworkDrive.corp.YYYY.com", "Files", "Folder", "Folder"]
server_parts = path_parts[0].split('.')         # ["NetworkDrive", "corp", "YYYY", "com"]
unc = "\\\\#{server_parts[0]}\\#{path_parts[1..-1].join('\\')}"
else
# afp://NetworkDrive/Folder/Folder/
 
parts = path.split('//') # ["afp:", "NetworkDrive/Folder/Folder"]
path_parts = parts[1].split('/') # ["NetworkDrive", "Files", "Folder", "Folder"]
unc = "\\\\#{path_parts.join('\\')}"
end
 
puts unc
----
 
The above old code gives something like this:

\\10\Department\....
 
What I now need is something that turns an OS X smb file path into the following:
 
file:////tnx3k/Department/....

Any help would be greatly appreciated!
 
 
 

 

Posted

It's not exactly clear what you want (you've given us some output, but not the corresponding input), but you can probably throw most of the code away and just replace "smb:" / "afp:" with "file://".

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...