How to send files discovered by glob to (default) printer
Question: I am trying to write a program that will take all the files with a specified
extension in a directory and print them consecutively. It would be great if
they could be printed more than once each time but one step at a time for now.

I plan to keep the .py file in the directory that I will be running the glob
on to avoid directory placeholder headaches...

I have tried the following:

    
    
    import os
    import glob
    
    os.startfile((glob.glob('*.docx*')), "print")
    

This gives me the following message:

    
    
        Traceback (most recent call last):
      File "C:\Users\cmobley\Desktop\HI\print all in folder.py", line 11, in <module>
        os.startfile((glob.glob('*.docx*')), "print")
    TypeError: Can't convert 'list' object to str implicitly
    

I understand there is some sort of missing link here I just can't put my
finger on it. I have also tried other approaches with no success. I have
successfully printed individual documents before using the os.startfile with
the print argument. I am very much so a beginner so please go easy on me! I am
using python 3.5 so my glob module is updated.


Answer: glob.glob returns a list of strings, you can't os.startfile a list, you have
to do it for each string in the list. That explains `TypeError: Can't convert
'list' object to str implicitly`

    
    
    import glob
    import os
    
    for filename in glob.glob('*.docx*'):
        os.startfile(filename, "print")
    

Multiple prints:

    
    
    import glob
    import os
    
    numPrints = 10
    
    for filename in glob.glob('*.txt*'):
        for i in range(numPrints):
            print("Printing file", filename, "copy", i+1)
            os.startfile(filename, "print")
    

