# Output Google Books Library XML Files to CSV
# For creating labels for new library books
# $UID is the primary key for the library system, make sure you select a free range
# the script auto increments $UID from the selected starting point for each book
[xml]$books = Get-Content D:\AR_Middle_years.xml
$UID = 9000
$bookObj = $books.library.books.book | ForEach-Object {
New-Object PSCustomObject -Property @{
"ISBN" = $_.identifier.value
"Title" = $_.title
"Author" = $_.contributor
"ID" = $UID++
}
}
$bookObj | Select Title, Author, ISBN, ID | Export-Csv -NoTypeInformation -Path D:\Books.csv
Comments