Hello all.
i made the following script that creates a http alias desktop shortcut on the desktop for a given url address.
tell application “Finder”
make new internet location file at desktop to ¬
“http://www.google.co.uk” with properties {name:“name of file”}
end tell
is there a way to add some more code on this script so i can add an icon as well (e.g. the safari icon).
Thanks in advance
This should do it. It has the default webloc image:
set startDocumentString 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>"
-- get url, name of new file and container of new file
set urlToOpen to "http://www.google.co.uk/"
set nameOfNewFile to "A HTTP Alias"
set containerOfNewFile to (path to desktop) as alias
set endDocumentString to "</string>
</dict>
</plist>"
set dataString to (startDocumentString & urlToOpen & endDocumentString) as string
tell application "Finder"
if nameOfNewFile does not end with ".webloc" then set nameOfNewFile to (nameOfNewFile & ".webloc") as string
try
make new file at containerOfNewFile with properties {name:nameOfNewFile}
set myFile to (file nameOfNewFile of containerOfNewFile) as alias
set OA to open for access myFile with write permission
write dataString to OA starting at 0
close access OA
on error theMsg
try
close access OA
end try
display dialog ("An error occured:" & return & return & theMsg) buttons "OK" default button 1
end try
end tell
hope it works,
ief2