Created
January 18, 2016 11:47
-
-
Save joemidi/6100ae1402da2ff2bcc9 to your computer and use it in GitHub Desktop.
Copy a server location
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on run | |
tell application "Finder" to set sel to selection | |
open sel | |
end run | |
on SAR(main_text, search_text, replace_text) | |
-- Search and Replace. Search for search-text in | |
-- main_text and replace it by replace_text. | |
set old_delims to AppleScript's text item delimiters | |
try | |
set AppleScript's text item delimiters to search_text | |
considering case | |
set parts to every text item of main_text | |
end considering | |
set AppleScript's text item delimiters to replace_text | |
set newText to (parts as string) | |
end try | |
set AppleScript's text item delimiters to old_delims | |
return newText | |
end SAR | |
on open theseItems | |
## this section grabs the IP address you want of the folder. | |
##set ipAdress to do shell script "netstat -n|grep '.548'|tr -s ' '|cut -d ' ' -f 5|sed 's/\\(.*\\)\\..*/\\1/'" | |
set ipAdress to "10.50.0.17" as text | |
## This Section Creates the Mac file path | |
set macFilePath to {} | |
repeat with oneFile in theseItems | |
set text item delimiters to ":" | |
set filePath to text items of (oneFile as text) | |
set text item delimiters to "/" | |
set end of macFilePath to filePath as text | |
end repeat | |
set macFilePath to macFilePath as text | |
set macFilePath1 to SAR(macFilePath, " ", "%20") | |
## This Section Creates the windows file path | |
set winFilePath to {} | |
repeat with oneFile in theseItems | |
set text item delimiters to ":" | |
set filePath to text items of (oneFile as text) | |
set text item delimiters to "\\" | |
set end of winFilePath to filePath as text | |
end repeat | |
set winFilePath to winFilePath as text | |
set winFilePath1 to SAR(winFilePath, " ", "%20") | |
set the clipboard to "******************************************" & return & "Mac Path: " & return & "afp://" & ipAdress & "/" & macFilePath1 & return & return & "If the link is broken, copy (apple+c) and paste (apple+v) whole link into Connect to Server (apple + k) " & return & return & "******************************************" & return & "Windows Path:" & return & "\\\\" & ipAdress & "\\" & winFilePath1 & return & return & "If the link is broken, copy (ctrl+c) and paste (ctrl+v) whole link into Windows Explorer " & return & return & "******************************************" | |
end open |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment