Here is just a little Visual Basic script I had to put together the other day. The whole thing or parts may be useful to people so I thought I would post it.
The script looks at each file in a specified folder and checks if it is a “Tiff image” if it is then an application is called to print the file and then the file is moved to another folder.
The script could easily be adapted for other file types or different tasks other than printing.
For this script I am using IrfanView to print the images mainly because it is a free image viewer, it has a /print and /silent switch and I already had it installed 😀
If like me you are printing a multi-page tiff or pdf files and find that IrfanView with the /slient switch only prints the first page. Then you need to print one image through the GUI, there is a little option on the print window to “print all page” the default is only the first.
This option gets saved in the applications settings .ini file and is used by the /slient mode.
On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
varInputPath = "c:\source folder"
varOutputPath = "c:\destination folder"
Set FolderToPrint = objFSO.GetFolder(varInputPath)
Set FilesToPrint = FolderToPrint.Files
For Each file in FilesToPrint
varFileName = file.name
varFileType = file.type
if varFileType = "TIF Image" Then
'Print the File
CMDRun = AddQuotes("C:\Program Files\IrfanView\i_view32.exe") & " " & AddQuotes(varInputPath & "\" & varFileName) & " /print /silent"
WSHShell.Run CMDRun, 2, true
'Move the file
Set aFile = objFSO.GetFile(varInputPath & "\" & varFileName)
aFile.Move varOutputPath & "\" & varFileName
End if
Next
'Get rid of any IrfanView processes
CMDRun2 = AddQuotes("C:\Program Files\IrfanView\i_view32.exe /killmesoftly /silent")
WSHShell.Run CMDRun2, 2, true
Function AddQuotes(strInput)
AddQuotes = Chr(34) & strInput & Chr(34)
End Function