// ISO_ChangeFootageFrameRate.jsx
// Artist: https://www.jasonfletcher.info/
// Code generated by ChatGPT-5
// Date: October 9, 2025
// Description: This After Effects script will prompt the user for the desired frame rate and then apply it to all selected footage items in the Project window.

{
    // Ask user for desired frame rate
    var fpsInput = prompt("Enter desired frame rate:", "60");

    if (fpsInput !== null) {

        var fps = parseFloat(fpsInput);

        if (isNaN(fps) || fps <= 0) {
            alert("Please enter a valid frame rate greater than 0.");
        } else {

            app.beginUndoGroup("Set Footage Frame Rate");

            var selectedItems = app.project.selection;

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

                var count = 0;

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

                    // Only apply to footage (not comps, folders, etc.)
                    if (item instanceof FootageItem && !item.mainSource.isStill) {
                        try {
                            item.mainSource.conformFrameRate = fps;
                            count++;
                        } catch (err) {
                            $.writeln("Error processing item: " + item.name + " — " + err.toString());
                        }
                    }
                }

                var totalSelected = selectedItems.length;
                var skipped = totalSelected - count;

                app.endUndoGroup();

                alert(
                    "Set frame rate to: " + fps + " fps\n" +
                    "Affected footage items: " + count + "\n" +
                    "Skipped footage items: " + skipped
                );
            }
        }
    }
}