Change file name with Applescript

I have a simple script that used to work but now it doesn’t:

				tell application "Finder"
					set name of file mypath to mynewname
				end tell

Now it gives me this error:

error “Finder got an error: Can’t set name of file "filepath" to "newfilename".” number -10006 from name of file “filepath”

What am I missing?

we need more information, like what is the value of “mypath”?

I tried to simplify but the actual error with the values is this:

error “Finder got an error: Can’t set name of file "Macintosh HD:Users:BColley:Library:CloudStorage:OneDrive-AAFP:Annals:2024:4.jul.aug 22.4:Production 22.4:velasquez:velasquezfig2.c.eps" to "279velasquezfig2.c.eps".” number -10006 from name of file “Macintosh HD:Users:BColley:Library:CloudStorage:OneDrive-AAFP:Annals:2024:4.jul.aug 22.4:Production 22.4:velasquez:velasquezfig2.c.eps”

Have a look at this thread:

Have you upgraded your computer’s OS?

The path that I see in the error message puts the file in the Library, so it may be protected from editing unless security requirements are met (especially if the script is actuall an ‘app’).

Can your script rename a file that is somewhere else? Like on the desktop?

I just tested a similar script to rename a file in my OneDrive (just like the OP’s file), and all I know is that it works for me on 13.6.