Thank you so much, this is great stuff! I’ve been looking for that some time now – always gave up. (And didn’t want to spend money on a script that performs 3 steps.)
When I executed your script, I always came out with an empty project. Maybe because I did not go through the Extend Script Toolkit? I wanted to make it executable through “Run Script File…” in AE, so I made some changes and simplified it a bit. (mainly to understand better what I am doing).
I reset to the original project simply by executing an “Undo Reduce Project” Command. So please note this only works if your using the english UI. The only thing you’ll need to translate in the code is the “Undo Reduce Project” part (Line 9), if you want to get it to work in other languages. I think from here it should be easy to add some gimmicks, like prompting for a different saving location.
var orgFIleUrl = app.project.file;
var orgName= app.project.file.name;
var comp = app.project.activeItem
var rootfolder = orgFIleUrl.toString ().substr (0, orgFIleUrl.toString ().lastIndexOf ('/'));
var comp = app.project.activeItem;
var fileLoc = new File(rootfolder + "//" + comp.name +".aep");
app.project.reduceProject(comp);
new_project = app.project.save(fileLoc);
app.executeCommand(app.findMenuCommandId("Undo Reduce Project"));
var fileLoc = new File(rootfolder + "//" + orgName);
new_project = app.project.save(fileLoc);