This would be one way to loop through all comps and combine your two functions:
var myComp, myLayer, myTextLayer, myAudioLayer;
for (var i = 1; i <= app.project.numItems; i++){
myComp = app.project.item(i);
if (! (myComp instanceof CompItem)) continue;
for (var j = 1; j <= myComp.numLayers; j++){
myLayer = myComp.layer(j);
if (myLayer.hasAudio){
myLayer.outPoint = myLayer.inPoint + myLayer.source.duration;
}
}
for (var j = 1; j <= myComp.numLayers; j++){
myTextLayer = myComp.layer(j);
if (myTextLayer instanceof TextLayer){
try{
myAudioLayer = myComp.layer(myTextLayer.name + ".mp3");
}catch (err){
myAudioLayer = null;
}
if (myAudioLayer == null) continue;
myTextLayer.startTime = myAudioLayer.inPoint;
myTextLayer.outPoint = myAudioLayer.outPoint;
}
}
}