33 lines
1.2 KiB
PowerShell
33 lines
1.2 KiB
PowerShell
|
[CmdletBinding()]param(
|
||
|
[string[]]$SrcPath,
|
||
|
[string]$FilePattern="*.tif",
|
||
|
[int]$PageNumberDigits=3,
|
||
|
[switch]$Force
|
||
|
)
|
||
|
|
||
|
Remove-TypeData -TypeName "ImageMagickPagesz" -ErrorAction Ignore -Confirm:$false
|
||
|
Update-TypeData -TypeName "ImageMagickPagesz" -DefaultDisplayPropertySet 'ImageMagickPath', 'Page' -Force -Confirm:$false
|
||
|
|
||
|
$local:PageNumberFormat="D$PageNumberDigits"
|
||
|
Get-ChildItem $(Join-Path $SrcPath $FilePattern) -Force:$Force |
|
||
|
ForEach-Object {
|
||
|
$local:f = $_;
|
||
|
& magick identify $f.FullName | ForEach-Object {
|
||
|
$local:p = [ordered]@{
|
||
|
PSTypeName = "ImageMagickPagesz"
|
||
|
PSFile = $f
|
||
|
BaseName = $f.BaseName
|
||
|
ImageMagickPath = $_ -ireplace " TIFF \d+x\d+ \d+x\d+\+\d+\+\d .*$",""
|
||
|
Page = 0
|
||
|
PageOutputName = [string]::Empty
|
||
|
}
|
||
|
if( $p.ImageMagickPath -match '.*\[(\d+)\]$' ) {
|
||
|
$p.Page = $matches[1]
|
||
|
}
|
||
|
|
||
|
$p.Page = $(0+$($p.Page)).ToString($PageNumberFormat)
|
||
|
$p.PageOutputName = "$($p.BaseName)_$($p.Page)"
|
||
|
|
||
|
[PSCustomObject]$p
|
||
|
}
|
||
|
}
|