メインコンテンツへスキップ

After Effectsプロジェクト内の選択されたアイテムの名前を一括で変更するスクリプト

    概要

    このツールの主な機能は、After Effectsプロジェクト内の選択されたアイテムの名前を一括で変更することです。

    使い方


    画像
    1. 文字列置換機能:

      • 「置き換え」フィールドに置換前と置換後のテキストを入力できます。この機能は、選択されたアイテムの名前に含まれる特定のテキストを別の文字列に置換するために使用されます。

    2. 文字列追加機能:

      • 「最初につける」と「最後につける」のフィールドを使用して、アイテムの名前の最初または最後に特定の文字列を追加できます。

    3. 文字列削除機能:

      • 「最初から文字消す」と「最後から文字消す」のフィールドを通じて、アイテムの名前の最初または最後から特定数の文字を削除することができます。

    4. 一括処理:

      • 「Rename」ボタンを押すと、上記の設定に基づいて選択された全てのアイテムの名前を一括で変更します。
        デフォルト状態のテキストフィールドは無視されます。

    コード

    /*
    ================================================================================
    					                
                              ItemRenamer
    
    ================================================================================
    
     【対象OS】
         Microsoft Windows 10
         Microsoft Windows 11
    
     【AE ver】
         cc2021動作確認済み
         cc2022動作確認済み
         cc2023動作確認済み
    
     【ライセンス】
         1.本スクリプトは再配布、または販売は明示的に禁止されます。
         2.の使用またはその他の取引に関連するいかなる請求、損害、またはその他の責任についても責任を負いません。
         
    
    ================================================================================
    */
    // ウィンドウオブジェクトの作成
    var winObj = new Window('palette', 'ItemRenamer', [0, 0, 270, 300]);
    
    // メインパネルの設定
    var compSettingPnl = winObj.add('panel', [5, 5, 265, 260], 'MainPanel');
    
    // ウィンドウの中央表示と要素の追加
    if (winObj instanceof Window) {
        winObj.center();
    
        // 置換用テキストエリアの追加
        var centerReplaceEditText = compSettingPnl.add("statictext", [5,5,200,30], "置き換え");
        var beforeReplaceEditText = compSettingPnl.add("edittext", [0,30,125,50], "");
        var afterReplaceEditText = compSettingPnl.add("edittext", [150,30,270,50], "");
        var centerReplaceEditText = compSettingPnl.add("statictext", [135,30,150,50], "\t->\t");
    
        // 「最初につける」テキストとエディットボックス
        var firstStaticText = compSettingPnl.add("statictext", [5,65,200,85], "最初につける");
        var firstEditText = compSettingPnl.add("edittext", [5,85,200,105], "");
    
        // 文字消去関連のUI設定
        compSettingPnl.add("statictext", [5,110,55,130], "最初から");
        var firstDelEditText = compSettingPnl.add("edittext", [55,110,100,130], "0");
        compSettingPnl.add("statictext", [105,110,160,130], "文字消す");
    
        // 「最後につける」テキストとエディットボックス
        var endStaticText = compSettingPnl.add("statictext", [5,140,200,160], "最後につける");
        var endEditText = compSettingPnl.add("edittext", [5,160,200,180], "");
    
        // 文字消去関連のUI設定
        compSettingPnl.add("statictext", [5,185,55,205], "最後から");
        var endDelEditText = compSettingPnl.add("edittext", [55,185,100,205], "0");
        compSettingPnl.add("statictext", [105,185,160,205], "文字消す");
    
        // Renameボタンの設定とクリックイベント
        var startBtn =  winObj.add("button", [90, 260, 180, 290], "Rename");
        startBtn.onClick = function() {
            app.beginUndoGroup("renameRun");
            rename(beforeReplaceEditText.text, afterReplaceEditText.text, firstEditText.text, Number(firstDelEditText.text), endEditText.text, Number(endDelEditText.text));
            app.endUndoGroup();
        }
        
        // ウィンドウの表示
        winObj.show();
    } else {
        // レイアウトの調整
        winObj.layout.layout(true);
        winObj.layout.resize();
    }
    
    //------------------------------------------------------------------------------
    // 名前変更機能
    //------------------------------------------------------------------------------
    
    function rename(beforeReplaceText, afterReplaceText, firstText, firstDelNum, endText, endDelNum) {
        selItems = app.project.selection;
        for (i = 0; i < selItems.length; i++) {
            item = selItems[i];
            item.name = item.name.slice(firstDelNum);
            if (endDelNum > 0) {
                item.name = item.name.slice(0, endDelNum * -1);
            }
    
            item.name = item.name.replace(beforeReplaceText, afterReplaceText);
            item.name = firstText + item.name;
            item.name = item.name + endText;
        }
    }
    

    ファイル


    不具合やご要望に関しては、X(旧Twitter)のDMにて承っております。

    あなたへのおすすめ