Skip to content

Commit

Permalink
made a python script for copying files in many subdirs to a dir
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsvetan Tsvetanov committed Jun 28, 2013
1 parent 9eba2af commit e936fc7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions python/copySubDirFiles.py
@@ -0,0 +1,14 @@
import os, fnmatch, shutil

def FindAllFiles(pattern, path):
result = []
for root, dirs, files in os.walk(path):
for name in files:
if fnmatch.fnmatch(name, pattern):
result.append(os.path.join(root, name))
return result

def CopyFoundFiles(fileNamePattern, sourceDir, destinationDir):
files = FindAllFiles(fileNamePattern, sourceDir)
for foundFile in files:
shutil.copy(foundFile, destinationDir)

0 comments on commit e936fc7

Please sign in to comment.