Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'One way to share links to networked files' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
One way to share links to networked files
Authored by: chleuasme on Mar 23, '09 08:18:36AM
Unlike the web, OS X provides no way to "bookmark" a file.
Ever heard about .fileloc files?

[ Reply to This | # ]
One way to share links to networked files
Authored by: chleuasme on Mar 23, '09 09:32:13AM
An example script that (should) create .fileloc files of selected items in the finder (ideally place this as an application in Finder's window toolbar) :
set fileloc_begin to "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
<plist version=\"1.0\">
<dict>
	<key>URL</key>
	<string>file://"

set fileloc_end to "</string>
</dict>
</plist>"

set cmd_txt to (quoted form of fileloc_begin) & "$furl" & (quoted form of fileloc_end)


tell application "Finder"
	set elts to get selection
	repeat with elt in elts
		set f to POSIX path of (elt as string)
		set fn to name of elt
		set p to POSIX path of ((container of elt) as string)
		set furl to do shell script "/bin/echo -n " & f & " | ruby -ruri -p -e '$_=URI.encode$_'"
		set fileloc to quoted form of (p & fn & ".fileloc")
		do shell script "furl=" & furl & "; echo " & cmd_txt & " > " & fileloc
	end repeat
end tell
(note I'm not an expert in Applescript, so use at your own risk)

[ Reply to This | # ]
One way to share links to networked files
Authored by: michaelj on Mar 23, '09 09:53:17AM
I've used this cm module for years - PathSnagger from BergenStreet Software - http://www.bergenstreetsoftware.com/

[ Reply to This | # ]
One way to share links to networked files
Authored by: chleuasme on Mar 23, '09 12:41:08PM

Your post must be mistakenly placed as an answer to my applescript. Reading the description of this software, I can't see anthing related to what the script does: create a .fileloc file for every selected file or folder in the Finder (... with a bug for files contained in a folder whose name includes the char '/').



[ Reply to This | # ]
One way to share links to networked files
Authored by: Uncle Asad on Mar 23, '09 02:18:16PM
Once you get your file:// URI (filepath) and name (filename) set up, you can just use the following tell block instead of writing the plist skeleton yourself:
tell application "Finder"
	make new internet location file at desktop to 
		filepath with properties {name:filename}
end tell
Saves a lot of code and lets the Finder do all the heavy lifting.

[ Reply to This | # ]
One way to share links to networked files
Authored by: chleuasme on Mar 23, '09 04:08:58PM
Thanks!

If it can helps, I then give the new version of the two scripts

  • create .fileloc file for the selected items of the Finder:
    tell application "Finder"
    	repeat with elt in (get selection)
    		set filepath to POSIX path of (elt as string)
    		set filename to name of elt
    		set parentdir to container of elt
    		set fileurl to do shell script "/bin/echo -n file://" & filepath & " | ruby -ruri -p -e '$_=URI.encode$_'"
    		
    		make new internet location file at parentdir to fileurl with properties {name:filename}
    	end repeat
    end tell
    
  • create .afploc file for the selected items of the Finder:
    tell application "Finder"
    	repeat with elt in (get selection)
    		set filepath to do shell script "echo " & (POSIX path of (elt as string)) & " | sed 's:^/Volumes::'"
    		set filename to name of elt
    		set parentdir to container of elt
    		set s to text returned of (display dialog "Enter the afp server for " & filepath default answer "afp://")
    		set afpurl to s & (do shell script "/bin/echo -n " & filepath & " | ruby -ruri -p -e '$_=URI.encode$_'")
    		
    		make new internet location file at parentdir to afpurl with properties {name:filename}
    	end repeat
    end tell


[ Reply to This | # ]