Print All File in a Directory

Assume your put this vbs named YOUR_VBS_NAME.vbs in a directory that only has the files your want to print, and nothing more. It is good for printing massive of MS DOC files.

Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
Dim sCurPath
sCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
TargetFolder = sCurPath
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(TargetFolder)
Set colItems = objFolder.Items
Dim count
count = colItems.Count - 1

Dim processed
processed = 0

For Each item in colItems
   If InStr(item.NAME,"YOUR_VBS_NAME.vbs") = 0 Then
      processed = processed + 1
      WshShell.Popup processed & " of " & count  & " items processed", 5, "THE_DIALOG_BOX_TITLE"
   End If

This script will run the print command every five seconds. That 5 seconds is needed! It is because opening ms office too fast will make office crash.

  • vbscript/print_all_files_in_a_directory.txt
  • Last modified: 2018/10/16 10:02
  • by chongtin