Jump to content

Help needed: Share link to network drive/folder/file with Windows users


Recommended Posts

I work on a Mac in a Windows dominated work place and often have to send links to files and folders on network drives to other users using Windows PC.

 

Is there any way to create a workflow that copies the path to the folder and magically transforms it into a link that a Windows based user can click on?

Link to post

I work on a Mac in a Windows dominated work place and often have to send links to files and folders on network drives to other users using Windows PC.

 

Is there any way to create a workflow that copies the path to the folder and magically transforms it into a link that a Windows based user can click on?

 

Local or network? Example? Convert X to Y?

Link to post

Local or network? Example? Convert X to Y?

 

Network.

 

Convert this:

smb://NetworkDrive.corp.YYYY.com/Files/Folder/Folder

 

To this:

\\NetworkDrive\files\Folder\Folder

 

 

 

- and - 

 

Convert this:

afp://NetworkDrive/Folder/Folder/

 

To this:

\\NetworkDrive\Folder\Folder\

Link to post

Network.

 

Convert this:

smb://NetworkDrive.corp.YYYY.com/Files/Folder/Folder

 

To this:

\\NetworkDrive\files\Folder\Folder

 

 

 

- and - 

 

Convert this:

afp://NetworkDrive/Folder/Folder/

 

To this:

\\NetworkDrive\Folder\Folder\

 

Create a workflow, trigger it with a keyword that requires an argument, connect it to run a script, choose Ruby as the script language, and paste this in:

 

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

 

Then connect a copy to clipboard output (or large type or whatever else you like) to the script.

Link to post

Create a workflow, trigger it with a keyword that requires an argument, connect it to run a script, choose Ruby as the script language, and paste this in:

 

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

 

Then connect a copy to clipboard output (or large type or whatever else you like) to the script.

 

That seemed to do the trick.

 

Thanks for helping me out.

Link to post
  • 6 months later...

I'm a new to Alfred workflows as of today after finding this post through a quick google search. This is something I'm dying to get working, but I'm having an issue. 

 

Created the workflow with Keyword "Share" with argument required > Connected to Ruby script and pasted the above > Connected to copy to clipboard

 

Basically, I want to highlight the folder on the shared drive in finder, copy the location and send that link to the people in my department who are on PCs. When I launch alfred and type the keyword, the alfred launcher remains on the screen and it looks like the script isn't running. Nothing copied to the clipboard. 

 

What am I forgetting in the process? Thanks for the help in advance.

 

---

 

Never mind. I think I figured it out. I was missing a key step like pasting the smb location into the alfred window. Now, is there a way to create a workflow that copies the smb location of a folder or file to the clipboard so I don't have to right click > get info > manually copy smb location?

Edited by mellow
Link to post
  • 6 months later...

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...