-
Notifications
You must be signed in to change notification settings - Fork 7
/
convert-opera-bookmarks.sh
executable file
·60 lines (51 loc) · 1.06 KB
/
convert-opera-bookmarks.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh -e
unset path
if [ "$#" -ne 2 ]; then
echo "This script converts bookmarks from Opera's adr format to that used by Fifth."
echo "Usage: $0 input output"
echo
[ -f ~/.opera/bookmarks.adr ] && path="~/.opera/bookmarks.adr"
[ -f ~/.opera/opera6.adr ] && path="~/.opera/opera6.adr"
[ -n "$path" ] && echo "Example: $0 $path ~/.fifth/bookmarks"
echo
exit 0
fi
src=$1
dst=$2
IFS="
"
tab=" "
> "$dst"
type=0
awk 'BEGIN { RS="\n\n"; FS="\n\t" }
{ name=""; url=""; for (i = 2; i < NF; i++) {
if ($i ~ /^NAME/) {
name = $i
sub(/^NAME=/, "", name)
gsub(/\//, "\\\\", name)
# FLTK does not like fwd slashes in names
} else if ($i ~ /^URL/) {
url = $i
sub(/^URL=/, "", url)
}
}
if ($1 == "#FOLDER") {
if (length(name) < 1)
name="INVALID"
print "name " name
print "url "
print ""
} else if ($1 == "#URL") {
if (length(name) < 1)
name="INVALID"
if (length(url) < 1)
url="INVALID"
print "name " name
print "url " url
print ""
} else if ($1 == "-") {
print "name "
print "url "
print ""
}
}' < "$src" > "$dst"