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


Click here to return to the 'Easy conversion of multiple Safari .webloc to PC .url files' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Easy conversion of multiple Safari .webloc to PC .url files
Authored by: bluehz on Jul 31, '04 03:52:08PM
This works for me - can convert multiple files.
#!/bin/sh

if [ $# -lt 1 ]; then
echo << EOF "
Usage: `basename $0` "file1.webloc" "file2.webloc" ...

       Converts Mac style web location files into
       PC style internet shortcut files.
        
       Can convert multiple files listed on command line.
       Filenames with spaces must be quoted.
       
       ex: convert all .webloc files in given directory 
           to .url files
           
           `basename $0` *
"
EOF
fi

for i in "$@"
do
webloc_name=(`strings "$i/rsrc" | grep http | sed 's/^.//' | head -1`)
url_name="`echo "$i" | sed 's/.webloc/.url/g'`"
url="`strings "$i"/rsrc | grep http | sed 's/^.//' | head -1`"

cat << EOF >$url_name
[InternetShortcut]
URL=$url
EOF

echo "Conversion completed and saved as:"
echo "       $url_name"
echo ""
shift
done


[ Reply to This | # ]
Easy conversion of multiple Safari .webloc to PC .url files
Authored by: fsb on Sep 06, '05 07:55:16PM
Here's a modified version that makes an .html file instead, which redirects to the URL when opened. This conforms to the "HTML 4.01 Transitional" standard and should work as a web shortcut for any browser on any platform.

#!/bin/sh
# Easy conversion of multiple Safari .webloc to universal .html 
# redirection files which should work with any browser.

if [ $# -lt 1 ]; then
echo << EOF "
Usage: `basename $0` "file1.webloc" "file2.webloc" ...

       Converts Mac style web location files into
       HTML files which redirect to that web location.
        
       Can convert multiple files listed on command line.
       Filenames with spaces must be quoted.
       
       ex: convert all .webloc files in given directory 
           to .html files
           
           `basename $0` *
"
EOF
fi

for i in "$@"
do
webloc_name=(`strings "$i/rsrc" | grep http | sed 's/^.//' | head -1`)
html_name="`echo "$i" | sed 's/.webloc/.html/g'`"
url="`strings "$i"/rsrc | grep http | sed 's/^.//' | head -1`"

cat << EOF >$html_name
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META HTTP-EQUIV="REFRESH" CONTENT="0; $url">
<TITLE>Transferring to $url...</TITLE>
</HEAD>
<BODY>
<P ALIGN="CENTER">
Transferring to <A 
HREF="$url">$url</A>  
<BR><BR>
Click the link if nothing seems to be happening.
</P>
</BODY>
</HTML>
EOF

echo "Conversion completed and saved as:"
echo "       $html_name"
echo ""
shift
done


[ Reply to This | # ]
Easy conversion of multiple Safari .webloc to PC .url files
Authored by: amitjain on May 05, '06 03:48:33AM

As i am a new user so please ignore my mistakes.
Problem...
I have used this code but the resultant .url file made by running this is:
1.when i run the file through shell script the file does not open on safari.
2.when i run the file through applescript the converted file has the url like this:
ttp://www.cnn.com i.e. h is missing. ihave checked the code thouroghly but unable to find the mistake.
please try to solve it.
Thankyou



[ Reply to This | # ]