里是按时间自动分文件夹的,一个一个文件夹拷很是麻烦,于是打算写个python小脚本来完成这个工作(扯这么多,终于
到主题了,囧)
废话少说,上代码:
代码如下:
# -*- coding: utf-8 -*-
#!/usr/bin/python
#Filename:copyfile.py
import os,shutil
def mycopy(srcpath,dstpath):
if not os.path.exists(srcpath):
print "srcpath not exist!"
if not os.path.exists(dstpath):
print "dstpath not exist!"
for root,dirs,files in os.walk(srcpath,True):
for eachfile in files:
shutil.copy(os.path.join(root,eachfile),dstpath)
srcpath='e:\\pic'
dstpath='f:\\pictotal'
mycopy(srcpath,dstpath)
可以看出,python仅需短短几行的代码就完成了这个工作,还是很方便的。若用C++来实现代码就比这个长了。
可见,语言无所谓高低,能高效方便实现目标就好,不是吗?