Have you ever wanted to print all the files in a single folder regardless of the extension? Well if you have needed this, you are in luck. I had a client ask me if this was possible and quickly looked into Powershell to solve my problem. I found a cmdlet Print that lets you send files to print and began testing some different methods and found this script to be the best option for this situation.

Requirements:

  • Must have a default printer selected.
  • Must have a default program assigned to file types you are printing

Powershell code:

#Script written by Dane Fieber. Please use this script freely. Enjoy! #Print all files in a folder $useroutput = Read-Host(‘Would you like to view the files being printed? yes/no ‘) $dir = Read-Host(‘Enter the full folder path to print. i.e. C:\Folder\inside folder’) $files = Get-ChildItem $dir   foreach ($file in $files){ if ($useroutput -eq ‘yes’) { #Check for the users input on if to display files and pause between files. Start-Process -FilePath $file.fullName -Verb Print Write-Host ‘The current file printing is ‘$file.fullname’…..’ Pause #Added a pause here to slow down the printing process. } else{ #Will print all files without any pause. Start-Process -FilePath $file.fullName -Verb Print } }
As you can see the script is very simple and does not require a lot to actually do what you want. I have added a few things to the script to make it more user-friendly.
  1. Would you like to see the files being printed?
    1. Yes = Display file name being printed and pause after each file.
    2. No = Do not display the file name being printed and do not pause after each file.
  2. What directory would you like to print?
    1. Enter in the full path to the directory, E:\Test\Testing. This will support UNC paths, \\testshare\foldertoprint
Here is a short video of the script in action. No, I did not video the printer actually printing the papers but it would have been a nice touch for you all to see that.

Tech Support from Navisiontech… On-Demand and On Point

Try Navisiontech Support today! We offer 2 FREE hours of support for nearly ALL versions of Dynamics NAV, from version 3 to Business Central. Our support team is US based and will provide support not only for your ERP system, but also for SQL Server, EDI, supply chain management tools, and even code-level support.