Dynamically change opening app according to file folder

I created the following APP with Automator and select it as the default APP to open PDF files. enter image description here