Why does the code : os.popen('move *.bin tmp) only move one file?
Question: all,

Currently, I write a python code in WIN, i'd like to run the command line code

    
    
    move *.bin tmp
    

but only one file was removed.

How can I make popen to finish this task?

Best wish!


Answer: I suggest using Pythons own modules instead of Windows tools (as also Patrick
suggest). I think something like this will work:

    
    
    import glob
    import shutil
    
    dest = 'c:/tmp/'
    
    # Get all the files as a list with glob
    files = glob.glob('c:/files/*.bin')
    
    # move each file seperatly
    for filename in files:
        shutil.move(filename, dest)
    

Or to make it short:

    
    
    import glob, shutil
    for f in glob.glob('c:/files/*.bin'):
        shutil.move(f, 'c:/tmp/')
    

