Procedure to replace a file with a new one with the same name


#1

I would like to save a blueprint file in a folder other than the one where the database is. If I use the statement “saveblueprint” directly with the path to the folder where I want it put, it works fine except if there is already a file with the same name in the folder. Apparently, Panorama doesn’t want to replace an existing file.

So I tried to send the old file to the trash first, using “filerename” and again, it works fine unless there is already a file with the same name in the trash…

To be clear, the point is to save blueprints of the database to a git repository.

Am I missing something here? Is there a way to force the replacement of an existing file with a new one with the same name?


#2

I would use fileerase instead of filerename.


#3

I’m not sure if I understand the original post. I use saveblueprint all the time, and it has no problem replacing an existing blueprint with a new one.

However, in reading your message closely, perhaps there is already some file there that is not a blueprint? I’ve never tried that, maybe there is an error if that is the case. As Gary suggested, I would use fileerase instead of filerename. Of course that means that you can’t drag the removed file out of the trash if you change your mind, but considering your application, you could recover it using Git.

Yeah! The entire reason the blueprint feature was originally invented was for use with Git, so I’m glad to see someone else take advantage of that. All of the Panorama databases that are part of Panorama itself (libraries and wizards) are tracked in the same Git repo that contains the Objective-C code.


#4

Thanks to Gary for suggesting the fileerase statement.

And thanks to Jim for telling me “saveblueprint” should just work.

So I looked into it a little more and found the “problem” which isn’t one actually. It was just me being in too much of a hurry…

To determine if Panorama did move the file it exported, all I did was look at the “modified” date in the Finder, like I do for any other file, and in Tower (the GUI client I use for Git) for the changes. And since it didn’t change, I just supposed nothing had happened. But the panblueprint “file” is not a file but a package, and its date is not changed if its name remains the same even if something inside it has changed. And if nothing has changed inside, Git doesn’t show any change either, even though Panorama did, in fact, save a new copy.

So that’s it. Nothing to do, just use “saveblueprint” and it’s done. Great!