Torsten Bronger wrote:
> The following code
>
> from subprocess import call
> call(['cp', 'subdir/*.jpg', 'othersubdir/'])
>
> yields
>
> cp: call of stat for "subdir/*.jpg" not possible: File or directory not found
>
> (This may not be the real error message since it's back-translated
> from German.) I could use shell=True, however, what's going wrong
> here?
under Unix, it's the shell that expands glob patterns. individual commands
usually don't know anything about such patterns.
so if you run the "cp" command directly, it will look for a single file named
"subdir/*.jpg". if you run it via the shell, it will get a list of matching
files
from the shell.
here's a corresponding pure-python solution, btw:
import glob, shutil
for file in glob.glob("subdir/*.jpg"):
shutil.copy(file, "othersubdir")
</F>
--
http://mail.python.org/mailman/listinfo/python-list