I have countless .URL files, which I need to have ready access to. However, I cannot open these in any browser I currently use.
I need either a way of opening these files in Firefox (preferred browser), without relying on additional software.
OR, I need a tool to convert .URL files into .WEBLOC files, or a similar file type.
I’d much rather keep the .URL files, so that they may be readily accessible on that other Operating System, if needed.
If anybody has a solution for this dilemma, I send my thanks in advance. I appreciate any help offered.
You could try digging out the link data from the file, Jeremy.
I don’t use Firefox, and I’ve only tested on files that Safari can handle anyway - but this might get you started:
set l to read (choose file of type {"LINK"})
set d to text item delimiters
set text item delimiters to "URL="
if (count l's text items) is 2 then open location paragraph 1 of l's text item 2
set text item delimiters to d
If the choose file command won’t allow access to your files, then you could try skipping the filter. Just change the first line to:
If Firefox isn’t actually your default browser, try changing the fourth line to:
I wrote a converter for this. You need to save this shell script and call it with the AppleScript below it:
And now the AppleScript portion of dinner:
on run
set theFile to (choose file with prompt "Choose a Windows .URL file to convert into a Mac OS X .webloc file.")
tell application "System Events" to set parentForFile to (path of (container of theFile))
set {theFileAsPOSIX, parentForTheFileAsPOSIX} to {(POSIX path of theFile), (POSIX path of parentForFile)}
do shell script "cd" & space & quoted form of parentForTheFileAsPOSIX & space & "; /path/to/script/winurl2webloc.sh" & space & quoted form of theFileAsPOSIX
end run
You can easily augment this to be a droplet where it loops through multiple .URL files and creates .webloc files. I do the “get path to parent of file” operation in the AppleScript, because the shell script itself doesn’t need it (and I didn’t want to add it there in case someone wanted to run it inside Terminal).
Droplet example:
on open theFiles
repeat with theFile in theFiles
tell application "System Events" to set parentForFile to (path of (container of theFile))
set {theFileAsPOSIX, parentForTheFileAsPOSIX} to {(POSIX path of theFile), (POSIX path of parentForFile)}
do shell script "cd" & space & quoted form of parentForTheFileAsPOSIX & space & "; /path/to/winurl2webloc.sh" & space & quoted form of theFileAsPOSIX
end repeat
end open
I recommend putting the script in ~/bin/winurl2webloc.sh and calling it from there. Just a handy place to keep it.