MarsNielson Posted April 19, 2013 Share Posted April 19, 2013 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 comment
jdfwarrior Posted April 19, 2013 Share Posted April 19, 2013 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 comment
MarsNielson Posted April 19, 2013 Author Share Posted April 19, 2013 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 comment
ctwise Posted April 19, 2013 Share Posted April 19, 2013 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. MarsNielson and drking 2 Link to comment
MarsNielson Posted April 24, 2013 Author Share Posted April 24, 2013 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 comment
mellow Posted October 31, 2013 Share Posted October 31, 2013 (edited) 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 October 31, 2013 by mellow Link to comment
Stooovie Posted July 19 Share Posted July 19 Would it be possible to get a workflow that converts both ways automatically? As in, when I copy a Windows (\\) path, it would convert to Mac (//), and vice versa? I'm not a developer at all and this would help my partner at her corporate job tremendously. Thanks! Link to comment
vitor Posted July 21 Share Posted July 21 On 7/19/2024 at 6:04 PM, Stooovie said: Would it be possible to get a workflow that converts both ways automatically? Yes. This is even quite doable without any code, just a sprinkle of regular expressions. There you go. It can either use the Hotkey Trigger or Universal Action. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now