Skip to content

Instantly share code, notes, and snippets.

@dhinus
Created May 18, 2011 07:33
Show Gist options
  • Save dhinus/978148 to your computer and use it in GitHub Desktop.
Save dhinus/978148 to your computer and use it in GitHub Desktop.
Export Apple Mail RSS feeds to opml
#!/bin/bash
#
# Script to export Mail RSS subscriptions to an OPML file.
# Written by VividVisions.com
# http://www.vividvisions.com/2008/02/22/rss-subscriptions-aus-apple-mail-exportieren/
#
# Modified by Francesco Negri
# https://github.com/dhinus
IFS=$'\n'
path=`echo ~/Library/Mail/RSS`
filename="Mail Export.opml"
if [ ! -d $path ]
then
echo "Error: ~/Library/Mail/RSS not found."
exit 1
fi
echo '<?xml version="1.0" encoding="utf-8"?>
<opml version="1.0">
<head>
<title>Apple Mail Subscriptions</title>
<dateCreated>'`date +%Y-%m-%d' '%H:%M:%S' '%z`'</dateCreated>
</head>
<body>
<outline text="Apple Mail Import">' >$filename
for file in $(find "$path" -name Info.plist)
do
name=${file%.rss*}
name=${name##*/}
name=${name//\"/\'}
name=${name/&/&}
url=`grep '<string>http' "$file" | grep -o 'http[^<]*'`
echo "<outline type=\"rss\" xmlUrl=\"$url\" text=\"$name\" description=\"$name\" />" >> $filename
done
echo '</outline>
</body>
</opml>' >> $filename
echo "Done"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment