First of all, your example uses mv, which is a program in coreutils, not bash.
Using os.system() calls to external programs is considered poor style because:
- You are creating platform-specific dependencies
- You are creating version-specific dependencies (Yes, even coreutils change sometimes!)
- You need to check for the existence of external commands (and that they are in $PATH, and executable by the user etc.)
- You have to wrap the commands with error checking using their return code. It is much nicer to use in-language error-codes or exceptions. (os.system() does not let you parse stdout/stderr)
- You have to deal with quoting variables with spaces yourself (or escaping them)
- Python has already done the work for you by supplying the libraries!
Look up glob, for shell-like pattern matching (globbing), and shutil, as others have already mentioned. Otherwise, everything you need is already in the standard libraries.
import glob
import shutil
for extfile in glob.glob('*.ext'):
shutil.move(extfile,dest)
In addition, os.system() should not be used - take a look at the subprocess module instead.