|
|
Desktop Folder Action - Convert Safari .webloc to PC .url files
I spliced together this script from those found on this hint with a tutorial found on apple.com (see references in script) that will automatically convert .webloc files to .url files when dragged to the desktop.
Copy the code below into a new script (using Script Editor), for reference we will call it convert_webloc.scpt I placed the following .scpt file (convert_webloc.scpt) into COMPUTER NAME > Library > Scripts > Folder Action Scripts, but you could obviously place it anywhere. Then attached the script as a folder action... right-click (or cntrl + click) on the Desktop folder in your Home directory and select "Attach a Folder Action...". Select the script file (convert_webloc.scpt) and you are done! property devToolsPath : "/Developer/Tools/" -- path to free Apple Developer Tools -- source: http://www.apple.com/applescript/folderactions/05.html on adding folder items to this_folder after receiving these_items tell application "Finder" set this_name to the name of this_folder end tell repeat with i from 1 to number of items in these_items set this_item to item i of these_items set the item_info to info for this_item -- cont. from http://www.macosxhints.com/article.php?story=20040728185233128 (osteslag) if (this_item as string) ends with ".webloc" then -- get full paths set weblocPath to quoted form of POSIX path of this_item set urlPath to text 1 thru -9 of weblocPath & ".url'" -- 1) get URL from .webloc file set cmd to devToolsPath & "DeRez -e -only 'url ' " & weblocPath & ¬ " | grep '\/\* .* \*\/' | sed 's/^.*\/\* //;s/ \*\/$//' | tr -d '\n'" set theURL to do shell script cmd if theURL begins with "http" then -- 2) write URL to file set cmd to "echo '[InternetShortcut]" & (ASCII character 10) & ¬ "URL=" & theURL & "' > " & weblocPath do shell script cmd -- 3) rename file using MvMac now that we have Developer Tools anyway set cmd to devToolsPath & "MvMac " & weblocPath & " " & urlPath do shell script cmd end if end if end repeat end adding folder items to
Desktop Folder Action - Convert Safari .webloc to PC .url files
It is also possible to obtain the URL of a Loc file (having class internet location file) with the "location" property.
That will avoid using the DeRez utility. Also instead of do shell script for writing to the new file, it can be done with "open for access file" and write ....
Desktop Folder Action - Convert Safari .webloc to PC .url files
Desktop Folder Action - Convert Safari .webloc to PC .url files
I almost didn't respond because this website forced me to register in order to leave a reply, but I did, and then had to navigate back to this page 3 times. |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.40 seconds |
|