I've just had a similar problem, but there were no square brackets in my Sharepoint path.
The solution, was that the affected files had a Path and Name length greater than the files that worked and were over some built-in Sharepoint length restriction. I simply reduced the length of the file name and everything worked as expected!
I have no idea why length should have anything to do with it, but there you go.
ChatGPT had a lot to say about it, but removing square brackets from the Path and Filename and/or shortening the Path/Filename was its top recommendation.