Skip to content

Instantly share code, notes, and snippets.

@findix
Last active August 29, 2015 14:01
Show Gist options
  • Save findix/c27ecc0899861e5a27f1 to your computer and use it in GitHub Desktop.
Save findix/c27ecc0899861e5a27f1 to your computer and use it in GitHub Desktop.
遍历目录获取所有文件
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import os.path
import shutil
#需要遍历的目录
fromDir='.\\'
#文件汇总到的目录
toDir='..\\result\\'
list_dirs = os.walk(fromDir)
for root, dirs, files in list_dirs:
for f in files:
print os.path.join(root, f)
# shutil.copy(os.path.join(root, f), toDir+f)
print "All Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment