我正在寻找一种在python中搜索%systemdrive%以查找pdf文件并将它们复制到我的usb驱动器的方法。
批量xcopy用于工作
X复制“$systemdrive%*.jpg”%~d0\%computername name% /s/c/q/r/h
但是windows7中的通配符将不再有效,因此在python中寻找替代方法。
发布于 2013-03-14 02:17:51
试试这个,可以帮助你:
import os
import shutil
for dirname, dirnames, filenames in os.walk(r'C:\znc\resp\A'):
for filename in filenames:
if os.path.splitext(filename)[-1] == '.pdf':
shutil.copy2(r'%s\%s' %(dirname,filename), r'D:\resp\B')
这行得通,但我不知道这是不是最好的
https://stackoverflow.com/questions/15391742
复制相似问题