Python Windows File Copy with Wildcard Support
Posted
by Wang Dingwei
on Stack Overflow
See other posts from Stack Overflow
or by Wang Dingwei
Published on 2010-04-06T11:29:34Z
Indexed on
2010/04/06
11:33 UTC
Read the original article
Hit count: 504
I've been doing this all the time:
result = subprocess.call(['copy', '123*.xml', 'out_folder\\.', '/y'])
if result == 0:
do_something()
else:
do_something_else()
Until today I started to look into pywin32 modules, then I saw functions like win32file.CopyFiles(), but then I found it may not support copying files to a directory. Maybe this functionality is hidden somewhere, but I haven't found it yet.
I've also tried "glob" and "shutil" combination, but "glob" is incredibly slow if there are many files.
So, how do you emulate this Windows command with Python?
copy 123*.xml out_folder\. /y
© Stack Overflow or respective owner