Skip to content

Commit 55fb608

Browse files
committed
search for files in subdir of clip dir
1 parent f1cc716 commit 55fb608

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

main.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ def check_output_dir(path):
2626
return
2727

2828

29-
def output_file_name(input_name, output_name, number_of_input_files):
29+
def output_file_name(input_path, output_name, number_of_input_files):
3030
"""
3131
Set the name for the output file from each clip process
3232
If more than 1 input file to be clipped, default behaviour should be used
3333
If only one input file passed, and output file name not set, use default behavior
3434
If only one input file passed, and the output file name is passed, use output file name
3535
"""
36-
input_name, input_extension = input_name.split('.')
37-
36+
input_path, input_extension = input_path.split('.')
37+
input_name = input_path.split('/')[-1]
3838
if number_of_input_files > 1 or output_name is None:
3939
output_file = input_name + '_clip.' + input_extension
4040
else:
@@ -177,7 +177,12 @@ def get_crs_of_data(file, vector=False):
177177
logger.info(glob.glob(join(data_path,input_dir,'*'), recursive=True))
178178

179179
# get input file(s) - the data to clip
180-
input_files = [f for f in listdir(join(data_path, input_dir, data_to_clip_dir)) if isfile(join(data_path, input_dir, data_to_clip_dir, f))]
180+
input_files = []
181+
#input_files = [f for f in listdir(join(data_path, input_dir, data_to_clip_dir)) if isfile(join(data_path, input_dir, data_to_clip_dir, f))]
182+
for root, dirs, files in walk(join(data_path, input_dir, data_to_clip_dir)):
183+
for file in files:
184+
input_files.append(join(root,file))
185+
181186
if len(input_files) == 0:
182187
print('Error! No input files found! Terminating')
183188
logger.info('Error! No input files found! Terminating!')

0 commit comments

Comments
 (0)