Created
April 11, 2014 00:56
-
-
Save myazdani/10435103 to your computer and use it in GitHub Desktop.
file copying short cuts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import shutil | |
def copyFromListToPath(src_paths, dest_path): | |
for i in range(len(src_paths)): shutil.copy2(src_paths[i], dest_path) | |
def getFilesWithPath(path, filetype = ""): | |
return [os.path.join(path,f) for f in os.listdir(path) if f.endswith(filetype)] | |
def getFilesFromPath(path, filetype = ""): | |
return [f for f in os.listdir(path) if f.endswith(filetype)] | |
def copyRecursiveToPath(src_path, dest_path): | |
filepaths = [os.path.join(root,f) for root,_,files in os.walk(src_path) for f in files if (f != '.DS_Store')] | |
copyFromListToPath(filepaths, dest_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment