如何解决如何一次将一个子文件夹发送到打印机
我使用 Powershell 制作了代码,将文件夹子文件夹及其 pdf 和 jpg 文件复制到另一个文件夹。现在我尝试继续代码,以便主打印机一次打印一个子文件夹。
我只设法将 pdf 文件发送到打印机,打印顺序非常冒险。此外,打印机会无限期地继续运行,直到打印机关闭。
文件夹结构为:
- 子文件夹
- 子文件夹
- 1 子文件夹子文件夹
- 2 子文件夹子文件夹
- 3 子文件夹子文件夹
- 4 子文件夹子文件夹
3.子文件夹
$Source = 'C:\....'
$Destination = 'C:\...'
$FileToCopy = 'system.serviceModel.client.config'
Get-ChildItem -Path $Source -Recurse | ForEach-Object {
if ($_.PSIsContainer) {
# if it's a folder,create the new path from the FullName property
$targetFolder = Join-Path -Path $Destination -ChildPath $_.FullName.Substring($Source.Length)
$copyFile = $false
}
else {
# if it's a file,create the new path from the DirectoryName property
$targetFolder = Join-Path -Path $Destination -ChildPath $_.DirectoryName.Substring($Source.Length)
# should we copy this file? ($true or $false)
$copyFile = ($_.Name -like "*.pdf") -or ($copyFile = ($_.Name -like "*.jpg"))
}
# create the target folder if this does not exist
if (!(Test-Path -Path $targetFolder -PathType Container)) {
$null = New-Item -Path $targetFolder -ItemType Directory
}
if ($copyFile) {
$_ | Copy-Item -Destination $targetFolder -Force
}
Get-ChildItem -Path $Source -Recurse -include "*.pdf","*.jpg" |
where { ! $_.PSIsContainer } | %{ Start-Process -FilePath $_.Fullname -Verb print}
ps。子文件夹包含 xlsx 文件,但将它们转换为 pdf 文件似乎是在处理 VBA 的不同线程上。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。