Jump to content
Sign in to follow this  
MarsNielson

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?

Share this post


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?

Share this post


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\

Share this post


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.

Share this post


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.

Share this post


Link to post

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

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  
×
×
  • Create New...