我发现很难说出这个问题而无法找到我正在尝试做的事情的在线解决方案.
我知道如何使用以下脚本使用PDFTK将大型PDF拆分为单个页面:
pdftk your_file.pdf burst output your_directory/page_%02d.pdf
Run Code Online (Sandbox Code Playgroud)
但现在我希望每次到PDF拆分其他页面,让每一个新的PDF有两个(2)页面(例如网页1 + 2在一起,3 + 4页一起,5 + 6等).
我知道Acrobat会像冠军那样做,但我需要一些我可以从Powershell执行的东西.
我对替代方案/解决方法持开放态度,比如单个页面并在单次爆发后将它们组合成两个.
到目前为止,这是我的代码:
$Folders = Get-ChildItem -Path U:\Powershell\Move-Files\Clients |
?{$_.PsIsContainer} |
Select -ExpandProperty FullName
Get-ChildItem -Path U:\Powershell\Move-Files\Individual | ?{
!($_.PsIsContainer)
} | %{
#Part of the file to match
$File = ($_.name.substring(0,$_.basename.length-11))
$File = ($File -split '_')[1] + ", " + ($File -split '_')[0]
# Find matching Directory
$Path = $Folders | ?{$_ -match $File}
Move-Item -Path $_.FullName -Destination $Path -ErrorAction Silently Continue
Write-Host "Moved $_.FullName to $Path"
}
Run Code Online (Sandbox Code Playgroud)
基本上,我有很多命名的文件First_Last (MMM yyyy).pdf,这会获取每个文件并以 的格式创建一个变量,Last, First以便它可以进行部分匹配并将文件移动到目标文件夹(格式为Last, First …