Copy link to clipboard
Copied
Hello, I am wondering if is it possible via scripting, using the saveFrameAsPng() function, to automatically save to the same folder as the opened project file. Hoenstly, I tried to do this already and just as I ran the script, a bunch of my files and folders just dissapeared (thank god we have RAIDed clones drives). It was a major mistake to learn from, I won't post my code but to give oyu an idea of how I was going about it,
Despite never replying or marking answers correct when I help you out, I'll give you another chance as I'm feeling generous today!
It sounds like you were feeding the folder containing your project into the save location so it was overwriting the folder with a PNG of the same name. You do need to be careful when messing around in your file system using scripts.
You just need to add a file name for the png onto the file path for the project folder. In this example I've derived it from the comp na
...Copy link to clipboard
Copied
Despite never replying or marking answers correct when I help you out, I'll give you another chance as I'm feeling generous today!
It sounds like you were feeding the folder containing your project into the save location so it was overwriting the folder with a PNG of the same name. You do need to be careful when messing around in your file system using scripts.
You just need to add a file name for the png onto the file path for the project folder. In this example I've derived it from the comp name but you can name it however you like.
var activeItem = app.project.activeItem;
if (activeItem != null && activeItem instanceof CompItem) {
var PNGfile = new File(app.project.file.parent.absoluteURI + "/" + activeItem.name + ".png");
// if file doesn't already exist or user confirms it's ok to overwrite....
if (!PNGfile.exists || confirm(File.decode(PNGfile.absoluteURI) + " exists. Overwrite?")) {
activeItem.saveFrameToPng(0, PNGfile);
}
}
Copy link to clipboard
Copied
Thank you Paul for helping me out with this problem. Writing this short series of scripts for my team is my pet project away from the busy editing bay, so I apologize if I havent compeltely followed forum ettiquette. But I will say that your answers are always helpful. I've learned a lot since starting this scripting journey, due in no small part to your input with some of these begginer hurdles and seeing where my I need to recalculate my assumptions about how some of this works This answer is no exception, its clear and reads to me like a sentence and gives me some exposure to some commands and methods I have not yet explored (and will do so carefully). Thank you for your reply.