Backup bookmarks

Backup-bookmarks.ps1
This script make a bookmarks.htm file in c:\temp and copies it to the bookmarks folder and the backup folder:
 * H:\Dropbox\entities\B\BO\bookmarks\bookmark-backups\YYYY\

save-bookmarks.ps1 $pathToJsonFile = "$env:localappdata\Google\Chrome\User Data\Profile 2\Bookmarks"
 * 1) credits: Mostly to tobibeer and Snak3d0c @ https://stackoverflow.com/questions/47345612/export-chrome-bookmarks-to-csv-file-using-powershell
 * 2) Path to chrome bookmarks
 * 3) $pathToJsonFile = "$env:localappdata\Google\Chrome\User Data\Default\Bookmarks"

$htmlOut = 'C:\temp\Bookmarks.htm' $htmlHeader = @'  <!DOCTYPE NETSCAPE-Bookmark-file-1>

 Bookmarks Bookmarks  '@

$htmlHeader | Out-File -FilePath $htmlOut -Force -Encoding utf8 #line59

Function Get-BookmarkFolder { [cmdletbinding] Param( [Parameter(Position=0,ValueFromPipeline=$True)] $Node )
 * 1) A nested function to enumerate bookmark folders

Process {

foreach ($child in $node.children) {  $da = [math]::Round([double]$child.date_added / 1000000) #date_added - from microseconds (Google Chrome {dates}) to seconds 'standard' epoch. $dm = [math]::Round([double]$child.date_modified / 1000000) #date_modified - from microseconds (Google Chrome {dates}) to seconds 'standard' epoch. if ($child.type -eq 'Folder') {    "    $($child.name)" | Out-File -FilePath $htmlOut -Append -Force -Encoding utf8 "       " | Out-File -FilePath $htmlOut -Append -Force -Encoding utf8 Get-BookmarkFolder $child "       " | Out-File -FilePath $htmlOut -Append -Force -Encoding utf8 }  else {       "       $($child.name)" | Out-File -FilePath $htmlOut -Append -Encoding utf8 } #else url } #foreach } #process } #end function

$data = Get-content $pathToJsonFile -Encoding UTF8 | out-string | ConvertFrom-Json $sections = $data.roots.PSObject.Properties | select -ExpandProperty name ForEach ($entry in $sections) { $data.roots.$entry | Get-BookmarkFolder } ' </HTML>' | Out-File -FilePath $htmlOut -Append -Force -Encoding utf8 md -Force "H:\Dropbox\entities\B\BO\bookmarks\bookmark-backups\$(get-date -uformat %Y)" copy "C:\TEMP\Bookmarks.htm" "H:\Dropbox\entities\B\BO\bookmarks\bookmark-backups\$(get-date -uformat %Y)\bookmarks-$(get-date -uformat %Y-%m-%d@%H-%M-%S).htm" copy -Force "C:\TEMP\Bookmarks.htm" "H:\Dropbox\entities\B\BO\bookmarks\bookmarks.htm"
 * 1) copy
 * 2) copy "C:\TEMP\Bookmarks.htm" "C:\temp\bookmarks-$(get-date -uformat %Y-%m-%d@%H-%M-%S).htm"
 * 1) copy "C:\TEMP\Bookmarks.htm" "H:\Dropbox\entities\B\BO\bookmarks\bookmarks-$(get-date -uformat %Y-%m-%d@%H-%M-%S).htm"
 * 2) $(get-date -uformat %Y-%m-%d@%H-%M-%S)
 * 3) $(get-date -uformat %Y-%m-%d@%H-%M-%S)

Run this script from run prompt:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -ExecutionPolicy Bypass -File C:\apps\powershell\save-bookmarks.ps1

Manually

 * 1) CTRL+SHIFT+O
 * 2) click on the three vertical dot menu
 * 3) Export Bookmarks
 * 4) Save to H:\Dropbox\entities\B\BO\bookmarks\ as bookmarks-YYYY-MM-DD.html

Export-chrome-bookmarks.bat

H:\Dropbox\entities\B\BO\bookmarks\bookmark-backups\archive\

Links

 * http://robertsdesktop/mediawiki/index.php/Backup_bookmarks