Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Need Assistance Using the Printing All PDF FIles Script

$
0
0

So i am building my first powershell script and ran into a hurdle.  In short, when i print the pdf files in the script below, it is printing out two files that i opened in the past instead of the files that I specify in the script.  

This is the script i borrowed (which is excellent to find.. hopefully just needs a tweak :) )

http://powershell.com/cs/blogs/tips/archive/2011/03/01/print-all-pdf-files-in-a-folder.aspx

and here is my script.  I want to log the files in a location, print them, and then move them to another location.  

 

#Set Path

$path='c:\_print'

 

# Set date variables

$year=get-date -format yyyy

$month=get-date -format MM

$day=get-date -format dd

$date=get-date -Format MM-d-yyyy

$monthDay=get-date -format MM-dd

 

# Test if folder for the year exists and create it if it doesnt.

if(test-path $path\$year) {"there"} else {New-Item $path\$year\ -type directory}

 

#create the folder for the day

new-item $path\$year\$monthday\ -type directory 

 

#write the files in the folder to a log file in the folder

Get-ChildItem $path\*.pdf | out-file $path\$year\$monthday\log.txt

 

# print the files  

$printing=start-job{Get-ChildItem $path -filter *.pdf | Foreach-Object { Start-Process -filePath $_.FullName –Verb Print }}

 

wait-job $printing

receive-job $printing

 

#move the pdf's to a dated directory

move-item $path\*.pdf $path\$year\$monthday\


Viewing all articles
Browse latest Browse all 6937

Trending Articles