jeffharbert

Auto print PDF files

Jun 15th, 2016
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'This VBscript will print all PDF files in the C:\files\to_be_printed\ folder. It requires a PDF application that
  2. 'supports silent printing. Sumatra is main one I use. It will print one file every 15 seconds, then move
  3. 'all the files to the C:\files\printed\ folder. These paths may of course be changed within the script.
  4.  
  5. Set fso=CreateObject("Scripting.FileSystemObject")
  6. source="C:\files\to_be_printed\"
  7. target="C:\files\temp\"
  8. printed="C:\files\printed\"
  9.  
  10. Set fldr=fso.getFolder(source)
  11.  
  12. for each file in fldr.files
  13.         if right(lcase(file.name),4)=".pdf" then
  14.                 call mover(lcase(file.path))
  15.         end if
  16. next
  17.  
  18. sub mover(f1)
  19.     fso.MoveFile f1,target
  20. end sub
  21.  
  22. strComputer = "."
  23. TargetFolder = "C:\files\temp"
  24. Set objShell = CreateObject("Shell.Application")
  25. Set objFolder = objShell.Namespace(TargetFolder)
  26. Set objFSO = CreateObject("Scripting.FileSystemObject")
  27. Set colItems = objFolder.Items
  28.  
  29. For i = 0 to colItems.Count - 1
  30.     colItems.Item(i).InvokeVerbEx("Print")
  31.     wscript.sleep 15000
  32. Next
  33.  
  34. wscript.sleep 120000
  35.  
  36. Set fldr=fso.getFolder(target)
  37.  
  38. for each file in fldr.files
  39.         if right(lcase(file.name),4)=".pdf" then
  40.                 call mover2(lcase(file.path))
  41.         end if
  42. next
  43.  
  44. sub mover2(f1)
  45.     fso.MoveFile f1,printed
  46. end sub
Advertisement
Add Comment
Please, Sign In to add comment