// Isosceles_MoveTimeIndicatorFrames.jsx
// Code generated by ChatGPT-5.3
// Date: March 15, 2026
// Description: This script will open the selected comps in the Project window and move the Current Time Indicator to the target frame.

{
    // Ask user for frame number
    var userInput = prompt("Move CTI to which frame?", "20");

    if (userInput !== null) {

        var targetFrame = parseInt(userInput, 10);

        if (!isNaN(targetFrame) && targetFrame >= 0) {

            // Start undo group
            app.beginUndoGroup("Move CTI to Frame " + targetFrame);

            // Get selected items
            var selectedItems = app.project.selection;

            if (selectedItems.length === 0) {
                alert("Please select at least one composition in the Project panel.");
            } else {

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

                    // Only operate on compositions
                    if (item instanceof CompItem) {

                        // Convert frame → seconds
                        var targetTime = targetFrame * item.frameDuration;

                        // Open comp in viewer
                        item.openInViewer();

                        // Move CTI
                        item.time = targetTime;
                    }
                }
            }

            // End undo group
            app.endUndoGroup();

        } else {
            alert("Please enter a valid non-negative frame number.");
        }
    }
}