1

I am Currently using Brave browser. I have a lot of bookmarks and would like to download them on to a folder on my PC BUT as individual links.

How can I accomplish this?

I have managed to export all my bookmarks but its saved as a single html file. Perhaps there's a way to analyse the file and have the links saved out individually?

2
  • You could potentially do this with a Bash or PowerShell script. What OS are you using? – Worthwelle Jul 23 '19 at 22:07
  • I am running on windows 10 and OSX. Could you please share how I could do this? – Nors0_mano Jul 24 '19 at 11:11
0

I threw together a quick PowerShell script to do this for you. You'll need to update $bookmarks_file and $bookmarks_folder to point to where you need.

This unfortunately only works in Windows and won't help you with your Mac, as that has a different shortcut format and I don't have a Mac to test on.

$bookmarks_file = "bookmarks.html"
$bookmarks_folder = "C:\Users\Someone\Desktop\Shortcuts"
$matches = Get-Content $bookmarks_file -Raw | Select-String -Pattern 'HREF="([^"]*)"[^>]*>([^<]*)<'  -AllMatches | % { $_.Matches }

foreach ($match in $matches) {
    Write-Host $match.Groups[1].Value' '$match.groups[2].Value
    $filename = $match.groups[2].Value
    $invalidChars = [IO.Path]::GetInvalidFileNameChars() -join ''
    $re = "[{0}]" -f [RegEx]::Escape($invalidChars)
    $filename = $filename -replace $re
    $location = "$($bookmarks_folder)\\$($filename).lnk"
    $WshShell = New-Object -ComObject WScript.Shell
    $Shortcut = $WshShell.CreateShortcut("$location")
    $Shortcut.TargetPath = $match.Groups[1].Value
    $Shortcut.Save()
}

Explanation

  • $matches = Get-Content $bookmarks_file -Raw | Select-String -Pattern 'HREF="([^"]*)"[^>]*>([^<]*)<' -AllMatches | % { $_.Matches }

    This line reads the links and link titles from the bookmarks.html file into an array.

  • foreach ($match in $matches) will look through the array

  • Write-Host $match.Groups[1].Value' '$match.groups[2].Value writes the URL and title to the console for reference
  • $filename = $match.groups[2].Value saves the title of the favorite as the filename
  • $invalidChars = [IO.Path]::GetInvalidFileNameChars() -join '' $re = "[{0}]" -f [RegEx]::Escape($invalidChars) $filename = $filename -replace $re replaces any illegal characters in the filename
  • $location = "$($bookmarks_folder)\\$($filename).lnk" creates the full path, including the directory
  • $WshShell = New-Object -ComObject WScript.Shell $Shortcut = $WshShell.CreateShortcut("$location") $Shortcut.TargetPath = $match.Groups[1].Value $Shortcut.Save() creates the shortcut using the generated file path and the URL
1
  • Man, thank you so much, awfully kind of you.I will try right now and see how it goes – Nors0_mano Jul 28 '19 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.