Reputation: 6890
Firefox lets you export to HTML, and while I could write a script that uses regex to parse that into CSV I was curious if there were any existing utilities / Firefox addons that allowed us to directly export to CSV. Also interested if there is any way to import like this.
Upvotes: 6
Views: 5093
Reputation: 798
I believe such an extension does not exist as of yet, but I wanted to make you aware that you can also export your bookmarks to JSON format, which might make a conversion to CSV easier compared to working with the HTML export (... depending).
Mozilla's official Firefox support page Restore bookmarks from backup or move them to another computer mentions how to do this under "Manual backup", though I find navigating there via the browser menu bar easier:
Bookmarks > Show All Bookmarks
, click the star-shaped button and select Backup...
. This will prompt the Save File dialogue for a JSON file named bookmarks-YYYY-MM-DD.json
with the current date.
Edit: the closest solution to using a FF add-on is probably a JavaScript bookmarklet. I included code for a first simple version in a Gist over on GitHub. You'd run this with the HTML export of your bookmarks open in your browser.
Upvotes: 1
Reputation: 1351
I put this (Powershell script) together just for this question. I do not have a way to import though. See my comments in the code for explanation of what is happening. There is really more to a bookmark than the name and URL but these are the most essential pieces of data so that's all I collected for the CSV. Also, you have to export the bookmarks to HTML, what this does is convert that to a CSV file.
#set paths
#where your bookmarks.html is
$bkmarkPath = "C:/Users/jhancock/Desktop/test/FFbookmarks/bookmarks.html"
#where you want your CSV file to be.
$newCSVPath = 'C:/Users/jhancock/Desktop/test/FFbookmarks/bookmarks.csv'
#get the HTML and parse it out.
$bookmarkpage = New-Object -ComObject "HTMLFile"
$bookmarkpage.IHTMLDocument2_write($(Get-content $bkmarkPath -Raw))
#get the links, and link names and put into variable.
$atags = $bookmarkpage.all.tags("a") | % innerText;
$links = $bookmarkpage.links | % ie8_href
#clear the file if it exists
if (Test-Path $newCSVPath) {
clear-content $newCSVPath
}
#create a new csvfile if it doesn't exist
"""Name"",""URL""`n" | Out-File $newCSVPath -Append
#add number of lines equal to number of links
For ($i=0; $i -lt $links.length; $i++) {
"`n"""",""""" | Out-File $newCSVPath -Append
}
#sleep while file is created
start-sleep 2
#import our fresh CSV file
$csv = Import-Csv $newCSVPath -Header Name, URL | Select-object -skip 1
#populate our links and URLs into the CSV
$numItems = $links.Count
for ($i = 0; $i -lt $numItems; $i++) {
$csv[$i].Name = $atags[$i]
$csv[$i].URL = $links[$i]
}
#Generate the CSV!
$csv | Export-Csv $newCSVPath -NoTypeInformation
Upvotes: 1