Quote:
Originally Posted by Glsparks2
Yes. I will post in a little while.
|
Powershell script to modify a copy of metadata.db:
# Path to your copy of metadata.db
$LibraryPath = "location of your copy of the metadata.db"
Set-Location $LibraryPath
# Backup metadata.db
$timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
Copy-Item "metadata.db" "metadata.db.backup_$timestamp"
# Load SQLite assembly (adjust path if needed)
Add-Type -Path "location of System.Data.SQLite.dll"
$dbPath = Join-Path $LibraryPath "metadata.db"
$conn = New-Object System.Data.SQLite.SQLiteConnection("Data Source=$dbPath;Version=3;")
$conn.Open()
function Exec-SQL($sql) {
$cmd = $conn.CreateCommand()
$cmd.CommandText = $sql
$cmd.ExecuteNonQuery() | Out-Null
}
# Get existing columns from books table
$cmd = $conn.CreateCommand()
$cmd.CommandText = "PRAGMA table_info(books);"
$reader = $cmd.ExecuteReader()
$existingCols = @()
while ($reader.Read()) {
$existingCols += $reader["name"]
}
$reader.Close()
# Add flags INTEGER DEFAULT 1
if ($existingCols -notcontains "flags") {
Exec-SQL "ALTER TABLE books ADD COLUMN flags INTEGER DEFAULT 1;"
}
# Add isbn TEXT
if ($existingCols -notcontains "isbn") {
Exec-SQL "ALTER TABLE books ADD COLUMN isbn TEXT;"
}
# Add lccn TEXT (lowercase)
if ($existingCols -notcontains "lccn") {
Exec-SQL "ALTER TABLE books ADD COLUMN lccn TEXT;"
}
$conn.Close()
Write-Host "metadata.db updated successfully."