Getting Path to file for PC use

Hey all,

I’m a lonely mac user on a PC network. Many times, i need to send paths to files on our network (we’re all mapped to the same drive letters). But i can’t find an easy way to do this.

Do you think this is a good solution? and if so, can anyone help me out w/ it?

If i could drag a file to an applescript in my dock that would then copy the file path to my clipboard. I’d have to be able to add a preceding piece of text, like "O:\WebFiles" then the paths should be pretty much the same.

Thx

Not having a PC to test with, I’d suggest trying this: drag the file in question from its Finder window to your Script Editor window and drop it. At the cursor, you will get the unquoted posix path to the file. If you want that as an alias for your script, then enter in your script window:

set PCRef to (posix file "") as alias

put the cursor between the quotes and drag the file to the Script Editor window. Compile that and you’ll have the alias to the file as a result.

Thanks for the reply,

It kinda works.

This is the path i get in Script Editor:
/Volumes/Web/0a_local_2007/Projects/report.txt

But on PC, it would be:
O:\0a_local_2007\Projects\report.txt

So, I’d need to replace “/Volumes/Web/” with “O:” and all “/” with ""

Try something like this:

on run
	display dialog "Choose file or folders?" buttons {"Cancel", "Folders", "File"} default button 3 with icon note
	
	if button returned of result is "File" then
		choose file with multiple selections allowed without invisibles
	else
		choose folder with multiple selections allowed
	end if
	
	open result
end run

on open theseItems
	set ASTID to AppleScript's text item delimiters
	set itemList to {}
	
	repeat with thisItem in theseItems
		set AppleScript's text item delimiters to "/"
		set thisItem to text items 4 thru -1 of (POSIX path of thisItem)
		set AppleScript's text item delimiters to "\\"
		set end of itemList to "O:\\" & thisItem
	end repeat
	
	set AppleScript's text item delimiters to (ASCII character 13) & (ASCII character 10)
	set the clipboard to "" & itemList
	set AppleScript's text item delimiters to ASTID
end open

Man, that worked great!

How can I go the other way? I get paths sent to me. Is there any way to open a Finder window based on that PC path?

Thanks so much

Try something like this:

property pcPath : ""

try
	display dialog "Enter a PC path for an item in "/Volume/Web/":" default answer pcPath buttons {"Cancel", "Reveal"} default button 2
	set {text returned:pcPath} to result
	
	set macAlias to (text 4 thru -1 of pcPath)
	
	set ASTID to AppleScript's text item delimiters
	set AppleScript's text item delimiters to "\\"
	set macAlias to text items of macAlias
	
	set AppleScript's text item delimiters to "/"
	set macAlias to "/Volume/Web/" & macAlias
	set AppleScript's text item delimiters to ASTID
	
	try
		set macAlias to macAlias as POSIX file as alias
	on error errMsg number errNum
		if errNum is -1700 then
			display dialog "The item "" & macAlias & "" doesn't exist." with icon caution buttons {"Cancel"} default button 1
		else
			error errMsg number errNum
		end if
	end try
	
	tell application "Finder" to reveal macAlias
on error errMsg number errNum
	if errNum is -128 then error number -128 -- cancel
	
	display dialog "Error " & errNum & return & return & errMsg with icon caution buttons {"Cancel"} default button 1
end try

I continually get the error that the path doesn’t exist. I remove the /users/bruce part…and replaced it w/ what I think is the correct path.

Oops, that was my mistake. :rolleyes: I’ve edited the script above to use the right path for you.

wow, this is fantastic.

couple things. how could i go about making this more flexible (by having some sort of variable list at the beginning that users could edit what each letter is mapped to each mac volume)?

Also, when pasting the pc path and opening a mac window…some of our paths have spaces…so when they paste them (from firefox, etc.) a %20 shows up. That causes the script to fail.

Just as a bonus, how can I get the users’ clipboard automatically inserted into the text box that shows up when you click the pc2mac path version?

This is awesome, and definitely deserves a donation of some kind. Let me know the best way to help out.

Thanks again.