How to save without becoming the new file?

Like it says, how do I have my script save the file as FILENAME.blend, but not shift to actually -becoming- that file?? My problem is, the file saved is in another directory, and then the script stops because the files it needs to open are, of course, NOT in that new directory, because they’re back with the file orignally running the script!! It’s driving me insane!

Hello,

Do you want to sort of make a copy of your current file? I’m not sure if there’s an “official solution”, but you can try to save your file twice in a row using bpy.ops.wm.save_as_mainfile().
The first time you save your file you should dpecify a new location as a fulepath argument. The second time you save your file you should specify a previous location as a fulepath argument.

bpy.ops.wm.save_as_mainfile(filepath=new_location)
bpy.ops.wm.save_as_mainfile(filepath=old_location)

I actually tried that, but for some odd reason, I failed to make it go back to the parent directory, so it just saved more and more file, making me think of Mickey and the broomsticks :grimacing: