make a file hyper link from pc share to a mac share

Work is divided between mac users in the studio and pc users who communicate to the clients on the pc share. PDF files are sent for approval by attaching the file to our outlook email and sending on to the account manager, all within the same building.

The email system keeps breaking down simply because we overload it with PDF files

The idea is to place the pdf file into a folder on the windows pc users server, and then add a hyperlink to a new email window. The mac user can then add comments and send the email with the link to the account handler in the same company.

I did a manual test by dragging the pdf file from the pc server into terminal. This gave me a path /Volumes/GROUPS/DEWYNTERS_FOLDER_STRUCURE/ShowProductions/Betty_Blue_Eyes/BBE-Studio/BBE-Ads/BBE-Ads_2012/BBE-Ads_Apr_2012/BBE_Pink_Esc_a1.pdf

I then changed part of the path (/Voumes to \10.1.50.117) and all the ˜/’ to ˜', as per the example below

\10.1.50.117\groups\DEWYNTERS_FOLDER_STRUCURE\ShowProductions\Betty_Blue_Eyes\BBE-Studio\BBE-Ads\BBE-Ads_2012\BBE-Ads_Apr_2012\BBE_Pink_Esc_a1.pdf

I then past the link into an email and sent this to a pc user. The linked worked.

What I am looking for is to drag the pdf file from the pc sever share on to an applescript on the mac share, this will then open up a new email window from ˜Outlook 2011’application with the link pasted in to the main window, or the link saved onto the mac desktop

If you can help me I would be very grateful

Paul

You might want to make a droplet for this.

on open DroppedFiles
	-- code goes here
	display dialog "You dropped " & count items of DroppedFiles & " files." buttons {"OK"} default button 1
end open

on run --keep this in to remind users to drop files onto it
	display dialog "Drop files onto me." buttons {"Cancel"} default button 1
end run

Hi Paul,

I am having difficulties converting forward slashes “/” to back slashes "" in order to convert the POSIX path of files dropped, to PC equivalent.

Could anyone else answer this question please? (Or should I create a new topic?)

The problem is, when I escape a backslash with “\” any transformation seems to honor both backslashes!

set pcPathTmp to "WorkArea:Some_Directory:Another_Directory:HighRes-JPGs:Main:A1E87B.jpg"
repeat while pcPathTmp contains ":"
	set pcPathTmp to text 1 thru ((offset of ":" in pcPathTmp) - 1) of pcPathTmp & "\\" & text ((offset of ":" in pcPathTmp) + 1) thru end of pcPathTmp
end repeat

-- ----->"WorkArea\\Some_Directory\\Another_Directory\\HighRes-JPGs\\Main\\A1E87B_.jpg"

Hi Intoto.

thanks for looking into this. Would it help if you know the unicode for each character slash / = 002F and backslash \ = 005C

Paul

Try this for the slashes:

searchAndReplace("WorkArea:Some_Directory:Another_Directory:HighRes-JPGs:Main:A1E87B.jpg", ":", "/")


on searchAndReplace(txt, srch, rpl)
	set oldtid to AppleScript's text item delimiters
	set AppleScript's text item delimiters to {srch}
	set temp to every text item of txt
	set AppleScript's text item delimiters to {rpl}
	set temp to (temp as string)
	set AppleScript's text item delimiters to oldtid
	return temp
end searchAndReplace

Browser: Safari 533.19.4
Operating System: Mac OS X (10.6)

Hi divster,

Forward slashes are not a problem. If I change this to a backslash ("") within the script, that backslash has to be escaped (with another backslash), then the script returns the path having changed all “:”’ to “\”. :mad:

searchAndReplace("WorkArea:Some_Directory:Another_Directory:HighRes-JPGs:Main:A1E87B.jpg", ":", "\\")


on searchAndReplace(txt, srch, rpl)
	set oldtid to AppleScript's text item delimiters
	set AppleScript's text item delimiters to {srch}
	set temp to every text item of txt
	set AppleScript's text item delimiters to {rpl}
	set temp to (temp as string)
	set AppleScript's text item delimiters to oldtid
	return temp
end searchAndReplace

-----------> "WorkArea\\Some_Directory\\Another_Directory\\HighRes-JPGs\\Main\\A1E87B.jpg"

I have finally realised that the previous result is correct. It is just that the results window is also escaping the "" and if this is then written to a file or displayed in a dialog, it does only return one backslash!!

So, Paul,
Does this work for you?

set oLink to POSIX path of (choose file with prompt "Select your file" without invisibles)
set saveTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"/"}
set lastP to text items 4 thru -1 of oLink as string
set AppleScript's text item delimiters to saveTID
set volIP to "//10.1.50.117/"
set fLink to volIP & lastP
set finalLink to do shell script "echo " & quoted form of fLink & " | tr '/' '\\\\' > ~/Desktop/pcLink.txt"

This will result in a text file being created on your Desktop, called “pcLink.txt”
I do not have Outlook 2011, but if I wanted to create a new message in Microsoft Entourage, I would do the following:

set oLink to POSIX path of (choose file with prompt "Select your file" without invisibles)
set saveTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"/"}
set lastP to text items 4 thru -1 of oLink as string
set AppleScript's text item delimiters to saveTID
set volIP to "//10.1.50.117/"
set fLink to volIP & lastP
set finalLink to do shell script "echo " & quoted form of fLink & " | tr '/' '\\\\'"

tell application "Microsoft Entourage"
	activate
	set EMaddress to "all@emailaddress.com" -- Change as necessary
	set eMsubject to "Check this link" -- Change as necessary
	make new outgoing message with properties {recipient:EMaddress, subject:eMsubject, content:finalLink, has html:true}
end tell

This will create a new message in the drafts folder awaiting to be sent.

To actually send the email as well, add these two lines at the end of the “Microsoft Entourage” tell block (just before the “end tell” line.

set messID to the result
	send messID

I hope Outlook works in the same way as Entourage. If not I’m sure someone else could help out.
I know this is not a droplet, but I am sure it could easily be converted.

Intoto

Sorry for my late reply but I have been away for a few weeks. Hope you are well?

Thanks for the script, all working very well. I haven’t tried to set it with outlook yet.

Just another question. If i want to reverse the process, where the user picks the file up from the PC server and then places it on to a applescript file/droplet on their desktop and then the text file is written to the desktop, is that possible. The reason for this is the studio and pc users are changing the way pdf files are accessed. I am trying to cut down the amount of steps they have to do. If they move the file to the pc share, and then place the file back onto the script application/droplet this reduces the steps they take. It also limits them selecting the wrong file if they have to chose the file especially if there are a large number of files in the folder

Is it also possible to save the file as the link name rather then in a text file? Again this reduces the steps the studio take, so all they have to do is drag the file to the outlook application, which then opens a new email window with the link in the subject field.

As ever I feel I’m asking to much of you and both I and the studio appreciate all your help, If any of the above is not possible, what you have supplied is a lot better from where have started from and I thank you

All the best

Paul

Hi Paul,

I’m not sure I understand what you mean by ‘reverse the process’.

As this is an Applescript, it has to be run/initiated from a Mac! Therefore, any file that is selected (even from a PC share) will have forward slashes anyway? (Please let me know if I have misunderstood you).

As for saving the file with the name of the converted link, I think this should work…

set oLink to POSIX path of (choose file with prompt "Select your file" without invisibles)
set saveTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"/"}
set lastP to text items 4 thru -1 of oLink as string
set AppleScript's text item delimiters to saveTID
set volIP to "//10.1.50.117/"
set fLink to volIP & lastP
set docName to do shell script "echo " & quoted form of fLink & " | tr '/' '\\\\'" as text
set finalLink to do shell script "echo " & quoted form of fLink & " | tr '/' '\\\\' > ~/Desktop/" & quoted form of docName

Happy to of helped!

Having come from a reprographic background, working in a pre-press studio before, I am interested in how Applescript can be used to automate and simplify day to day (repetitive) routines.

Regards.

Hi Intoto

Thanks for the last draft. Sorry my explanation was not that clear.

If it was possible, the idea was to drop the file from the pc share onto the applescript icon (just the way we do for the folder structure you first created), and then it saves the text file with the path on to the users desktop.

The idea was to save time and the number of steps taken to place the linked path into an email.

Interestingly you come from a repro background. I’m a big believer in automation, and for simple things like the folder structure applescript which works like a dream. It’s great when you see the studio using it completely unaware how much time it is saving them. I’m constantly in ore of people like yourself and your skills in applescript. I’m trying to learn more about it but just keeping up with all the adobe programs, colour management, Rips, Video etc is a struggle.

Again many thanks for the script

Paul