// ISO_FolderTemplateCreator.jsx
// Artist: https://www.jasonfletcher.info/
// Code generated by GPT-5.3-mini
// Date: June 11, 2026
// Description: This After Effects script creates a folder structure following a template. The new folders will be created within the currently selected folder. Or if no folder is selected then the new folders will be created in root of project.
// 
// Template Folder Structure:
// * Comps
//     * 1 TODO
//     * 2 IN PROGRESS
//     * 3 TO RENDER
//     * 4 RENDERING
//     * 5 DONE
// * Footage

(function () {

    app.beginUndoGroup("Create Project Folder Structure");

    try {

        var proj = app.project;
        var parentFolder = proj.rootFolder;

        // Use selected folder if valid
        var sel = proj.selection;

        if (sel !== null && sel.length > 0) {
            if (sel[0] instanceof FolderItem) {
                parentFolder = sel[0];
            }
        }

        function makeFolder(name, parent) {
            var f = proj.items.addFolder(name);
            if (parent !== null) {
                f.parentFolder = parent;
            }
            return f;
        }

        var compsFolder = makeFolder("Comps", parentFolder);
        var footageFolder = makeFolder("Footage", parentFolder);

        makeFolder("1 TODO", compsFolder);
        makeFolder("2 IN PROGRESS", compsFolder);
        makeFolder("3 TO RENDER", compsFolder);
        makeFolder("4 RENDERING", compsFolder);
        makeFolder("5 DONE", compsFolder);

        alert("Folder structure created successfully.");

    } catch (err) {
        alert("Error:\n" + err.toString());
    } finally {
        app.endUndoGroup();
    }

})();