0

I would like the user to select 2 directories, each directory having their own defined algorithms. For example: First_Directory will add a column to all shapefiles in the chosen directory; Second_Directory will delete a column to all shapefiles in the chosen directory.

When selecting one directory and leaving the other blank, i.e. only First_Directory and leaving Second_Directory blank, the algorithms defined for First_Directory work fine and vice versa.

However when selecting for both, it seems that only First_Directory is processed. What I would like is, ofcourse, for both directories to be processed sequentially.

The code below is merely trying to show the logic, it's the IF statement that I am concerned about (whether or not it's even required in the first place!)

##Test=name
##First_Directory=folder
##Second_Directory=folder

path_1 = First_Directory
path_2 = Second_Directory
path = path_1 or path_2

os.chdir(path)

def First(path_1):
#Do some processing

def Second(path_2):
#Do some other processing

if path_1:
    score_1(path_1)
elif path_2:
   score_2(path_2)
elif path_1 and path_2:
    score_1(path_1)
    score_2(path_2)
else:
    pass

closed as off-topic by PolyGeo Nov 6 '17 at 10:24

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

2

Your question is not really GIS related. The problem is your condition (first if and first elif) are always being meet if either of the directories are being selected, then the code jumps out of the conditional statement.

You could switch the order of the conditions to:

if path_1 and path_2:
   score_1(path_1)
   score_2(path_2)
elif path_1:
   score_1(path_1)
elif path_2:
   score_2(path_2)
else:
   pass

Not the answer you're looking for? Browse other questions tagged or ask your own question.