Yes, I was just giving you an example to get you started. I'd generally suggest checking out AE's CS3 scripting guide and the Javascript Tools Guide pdfs for documentation, and posting questions along with your code so far when you get stuck. You can study the various examples on here and places like aenhancers.com to get a better understanding of the syntax.
And one minor point, expressions (javascript that controls a property value) and scripting (javascript that controls After Effects) aren't exactly the same thing. In this case we're talking about scripting, not expressions.
Here's an example that should be closer to what you want:
var frameRate = 30;
var maxDuration = 10;
var maxWidth = 10;
var maxHeight = 10;
var pixelAspect = 1;
var x,y, curItem, thisItem, theComp;
for (x = 1; x <= app.project.rootFolder.numItems; x++) { // loop through items in root folder only
curItem = app.project.rootFolder.item(x);
if (curItem.selected && curItem instanceof FolderItem) { // if it's selected and a folder
for (y = 1; y <= curItem.numItems; y++) { // loop through the folder's items
thisItem = curItem.item(y);
if (thisItem instanceof FootageItem) { // if it's footage
if (thisItem.hasVideo) { // if it has video
maxWidth = Math.max(maxWidth, thisItem.width); // record this footage width if largest
maxHeight = Math.max(maxHeight, thisItem.height); // record this footage height if largest
pixelAspect = thisItem.pixelAspect; // record aspect ratio
if (!thisItem.mainSource.isStill) { // if it isn't a still record frame rate and duration if longest
maxDuration = Math.max(maxDuration, thisItem.duration);
frameRate = thisItem.frameRate;
}
} else { // must be audio. record duration if longest
maxDuration = Math.max(maxDuration, thisItem.duration);
}
}
}
theComp = app.project.items.addComp(curItem.name, maxWidth, maxHeight, pixelAspect, maxDuration, frameRate); // add comp with max values and folder name
for (y = 1; y <= curItem.numItems; y++) { // loop through items in folder again, adding them to comp if they are footage
thisItem = curItem.item(y);
if (thisItem instanceof FootageItem) {
theComp.layers.add(thisItem);
}
}
}
}