How can I bump up shadows in post without overexposing the image?

I’m trying to create a Photoshop/Lightroom RAW processing preset to process 1200 images for photogrammetry. It’s important that the lighting on them is as flat as possible and the shadows get bumped up to reveal details.

On some images, such as this one, pushing up the shadows and pushing down the highlights gives great results, making the lighting flatter and revealing details hidden in the shadows.

On others, especially ones with bright sky in them, such as this one, the same exact settings make the photo way too bright, I’m guessing because, on average, the image is brighter. Notice that, even though the wall in both images is the same, the same settings make it look very different.

Is there a setting that will make both images work? It’s important that I don’t have to manually tweak each photo since there are so many of them. All images were shot with the same ISO, aperture, shutter speed, etc.