From 930d3bb958c58669c5d4d3b6ef8f167266118aeb Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Tue, 26 Jan 2010 14:09:09 +0000 Subject: [PATCH] Refactor find_files to use os.walk instead. --- tvorganise.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tvorganise.py b/tvorganise.py index a17c468..f7c1494 100755 --- a/tvorganise.py +++ b/tvorganise.py @@ -30,14 +30,11 @@ def find_files(args): files within) """ filelist = [] - for cfile in args: - if os.path.isdir(cfile): - for sf in os.listdir(cfile): - newpath = os.path.join(cfile, sf) - if os.path.isfile(newpath): - filelist.append(newpath) - elif os.path.isfile(cfile): - filelist.append(cfile) + + for root, dirs, files in os.walk(args, topdown=False): + for name in files: + filelist.append(os.path.join(root, name)) + return filelist