// Isosceles_StretchFootageInComps.jsx
// Code generated by ChatGPT-5
// Date: October 9, 2025
// Description: This After Effects script will apply a user-defined Stretch percentage to all footage layers within selected comps in the Project window.

(function applyStretchToFootageLayers() {
    app.beginUndoGroup("Set Stretch for Footage Layers");

    var selectedItems = app.project.selection;

    if (selectedItems.length === 0) {
        alert("Please select one or more compositions in the Project panel.");
        return;
    }

    // Prompt user for stretch percentage
    var stretchInput = prompt("Enter Stretch percentage for footage layers (e.g. 50 for 50%)", "50");

    // Validate input
    var stretchValue = parseFloat(stretchInput);

    if (isNaN(stretchValue)) {
        alert("Invalid input. Using default value of 50%.");
        stretchValue = 50;
    }

    for (var i = 0; i < selectedItems.length; i++) {
        var item = selectedItems[i];

        // Only process compositions
        if (item instanceof CompItem) {
            var comp = item;

            for (var j = 1; j <= comp.numLayers; j++) {
                var layer = comp.layer(j);

                // Check if layer is a footage layer
                if (layer.source && layer.source instanceof FootageItem) {
                    layer.stretch = stretchValue;
                }
            }
        }
    }

    app.endUndoGroup();
})();