
Actualmente estoy usando el navegador Brave. Tengo muchos marcadores y me gustaría descargarlos en una carpeta de mi PC, PERO como enlaces individuales.
¿Cómo puedo lograr esto?
Logré exportar todos mis marcadores pero se guardó como un único archivo html. ¿Quizás haya una manera de analizar el archivo y guardar los enlaces individualmente?
Respuesta1
Preparé un script rápido de PowerShell para hacer esto por usted. Deberá actualizar $bookmarks_file
y $bookmarks_folder
señalar donde lo necesite.
Desafortunadamente, esto solo funciona en Windows y no te ayudará con tu Mac, ya que tiene un formato de acceso directo diferente y no tengo una Mac para probar.
$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()
}
Explicación
$matches = Get-Content $bookmarks_file -Raw | Select-String -Pattern 'HREF="([^"]*)"[^>]*>([^<]*)<' -AllMatches | % { $_.Matches }
Esta línea lee los enlaces y los títulos de los enlaces del
bookmarks.html
archivo en una matriz.foreach ($match in $matches)
mirará a través de la matrizWrite-Host $match.Groups[1].Value' '$match.groups[2].Value
escribe la URL y el título en la consola como referencia$filename = $match.groups[2].Value
guarda el título del favorito como nombre de archivo$invalidChars = [IO.Path]::GetInvalidFileNameChars() -join '' $re = "[{0}]" -f [RegEx]::Escape($invalidChars) $filename = $filename -replace $re
reemplaza cualquier carácter ilegal en el nombre del archivo$location = "$($bookmarks_folder)\\$($filename).lnk"
crea la ruta completa, incluido el directorio$WshShell = New-Object -ComObject WScript.Shell $Shortcut = $WshShell.CreateShortcut("$location") $Shortcut.TargetPath = $match.Groups[1].Value $Shortcut.Save()
crea el acceso directo utilizando la ruta del archivo generado y la URL