From 41309c46b0df2981d5484a1d44eb97f2b70ee31a Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Tue, 26 Jan 2010 16:31:00 +0000 Subject: [PATCH] Fix find_files to be able to handle str and list --- tvorganise.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tvorganise.py b/tvorganise.py index 2f3c8e0..bd1edbe 100755 --- a/tvorganise.py +++ b/tvorganise.py @@ -25,14 +25,18 @@ def same_partition(path1, path2): def find_files(args): """ - Takes a list of files/folders, grabs files inside them. Does not - recurse more than one level (if a folder is supplied, it will list - files within) + Take a singular path or a list of paths and provides a list of all files in + that directory structure. """ filelist = [] - - for path in args: - for root, dirs, files in os.walk(path, topdown=False): + + if isinstance(args, list): + for path in args: + for root, dirs, files in os.walk(path, topdown=False): + for name in files: + filelist.append(os.path.join(root, name)) + else: + for root, dirs, files in os.walk(args, topdown=False): for name in files: filelist.append(os.path.join(root, name))