diff options
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/feature_extraction/generate_file_list.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/examples/feature_extraction/generate_file_list.py b/examples/feature_extraction/generate_file_list.py new file mode 100755 index 00000000..c0dcb938 --- /dev/null +++ b/examples/feature_extraction/generate_file_list.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python +import os +import sys + +def help(): + print 'Usage: ./generate_file_list.py file_dir file_list.txt' + exit(1) + +def main(): + if len(sys.argv) < 3: + help() + file_dir = sys.argv[1] + file_list_txt = sys.argv[2] + if not os.path.exists(file_dir): + print 'Error: file dir does not exist ', file_dir + exit(1) + file_dir = os.path.abspath(file_dir) + '/' + with open(file_list_txt, 'w') as output: + for root, dirs, files in os.walk(file_dir): + for name in files: + file_path = file_path.replace(os.path.join(root, name), '') + output.write(file_path + '\n') + +if __name__ == '__main__': + main() |