Avoid error message: "Could not access the directory"?

Hi,

I ran multiple Mathematica files using the the NoteBookOpen/NoteboookEvaluate options. Now once the run is over, I am not able to save the files. I get the error message - “Could not access the directory. You should check the directory’s permission.”
Here is the part of my code to run the first of the files and so on…

File1 = NotebookOpen[ "C:/....."]; 
SelectionMove[File1, All, Notebook] 
SelectionEvaluate[File1]

Would be thankful for any suggestion.

What exactly are you doing to “save the files”?

I tried saving them as I usually do.. Either by Control+S or by going for “Save” or “Save As” options. Even quitting kernel was of no help.

Interestingly, I am able to save the files in any other folder with different names, which is very frustrating for large number of files. Would prefer to be able to save them by usual methd.

Will appreciate any help on that. Thanks

I suspect the error message is misleading. Mathematica probably has a handle to the open file which is preventing the save. Why not just use NotebookSave?

Perhaps not for the same reason, but I recently had the same problem. It was resolved by adding Mathematica (now Wolfram) to the apps with Full Disk Access (under system Privacy & Security settings). If you’ve arrived here looking for a solution, I suggest you give it a try.