Skip to content

Instantly share code, notes, and snippets.

@EndlessTrax
Last active October 24, 2023 21:19
Show Gist options
  • Select an option

  • Save EndlessTrax/18bc54863350f299cf816b8374d2d3f2 to your computer and use it in GitHub Desktop.

Select an option

Save EndlessTrax/18bc54863350f299cf816b8374d2d3f2 to your computer and use it in GitHub Desktop.
Find all eBooks in a folder, recursively.
[CmdletBinding()]
param (
[Parameter()]
[string]
$InputFolder,
[Parameter()]
[string]
$OutputFolder
)
$Formats = @(
"*.epub",
"*.mobi",
"*.azw"
)
# If a more than one book is found with the same name and format, just in a different folder, it will be
# overwritten so only one copy will remain.
foreach ($Format in $Formats) {
Get-ChildItem -Path $InputFolder -Filter $Format -Recurse | ForEach-Object {
Copy-Item -Path $_.FullName -Destination $OutputFolder
Write-Host "Copied $($_.Name) to $OutputFolder"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment