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