Skip to content

Instantly share code, notes, and snippets.

@skaboy71
Last active August 29, 2015 14:24
Show Gist options
  • Save skaboy71/d0c75f7da5a3c4f9a9f7 to your computer and use it in GitHub Desktop.
Save skaboy71/d0c75f7da5a3c4f9a9f7 to your computer and use it in GitHub Desktop.
## This script will print all pdf files in a specific folder in alphabetical order by file name.
## As an admin on the machine where you are running the script, from powershell you will need to run the command:
## Set-ExecutionPolicy Unrestricted
## Before you can run any powershell script on that machine.
## This will get all pdfs in the path designated as $folderPath, sort them by name alphabetically and then send each one to the default printer.
## Please change the path inside the double quotes on the first line to match the path you need to use.
Set-ExecutionPolicy Unrestricted
$folderPath = "C:\Yourpath\to\folder\here"
$folderPath = $folderPath + "\*.pdf"
$files = Dir $folderPath
$files = $files | Sort-Object name
# 5 second delay to allow each file to "spool". This might need to be adjusted depending on size of your files.
foreach($file IN $files){Start-Process -FilePath $file.FullName –Verb Print -PassThru | %{sleep 5;$_} | kill}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment