• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Ae scripting saveFrameAsPng() set to save to project location

Community Beginner ,
Apr 14, 2021 Apr 14, 2021

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,  

 
in the save location atribute of saveFramAsPng() function I had a variable projfolder
var projFolder = app.project.file.parent;
 
If anyone has any suggesitons on how to make the saveFrameAsPng() function save to the current projects folder it would be greatly appreciated. thank you.
TOPICS
Crash , Expressions , How to , Import and export , Scripting , SDK

Views

298

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Apr 14, 2021 Apr 14, 2021

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

...

Votes

Translate

Translate
Enthusiast ,
Apr 14, 2021 Apr 14, 2021

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);
	}

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 14, 2021 Apr 14, 2021

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines