• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Batch rename PS Artboards from excel list

Community Beginner ,
Jul 17, 2018 Jul 17, 2018

Copy link to clipboard

Copied

I have an excel list where one column is the name I want my photoshop artboard to be called. There are 50 items. In PS, I've got a file with 50 artboard named 'Artboard 1' to 'Artboard 50'.  Is there a way I could somehow link the spreadsheet to my PS file to batch rename the artboard names? Thanks in advance!

TOPICS
Actions and scripting

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
People's Champ ,
Jul 17, 2018 Jul 17, 2018

Copy link to clipboard

Copied

On Windows it is possible to do using an external temporary js script.

var xls_path = "C:\\1.xlsx"; // path to xls file

var file = export_office_file(xls_path, "xls");

var array = new Array();

if (file)

    {

    file = new File(file);

    file.open("r")

    while(1)

        {

        var txt = file.readln();

        if (file.error) break;

        array.push(txt);

        }

   

    file.close();

    file.remove();

    }

var cnt = 0;

for (var i = 0; i < array.length; i++)

    if (select_layer("Artboard " + (i+1))) { activeDocument.activeLayer.name = array; ++cnt; }

alert(cnt +  " layers have been renamed");

function select_layer(name)

    {  

    try {

        var r = new ActionReference();

        r.putName( charIDToTypeID( "Lyr " ), name);

        var d = new ActionDescriptor();

        d.putReference( charIDToTypeID( "null" ), r );

        d.putBoolean( charIDToTypeID( "MkVs" ), false );

        var ok = true;

        try { executeAction( charIDToTypeID( "slct" ), d, DialogModes.NO ); } catch(e) { ok = false; }

        return ok;

        }

    catch (e) { alert(e); throw(e); return false; }

    }

function export_office_file(file_path, type)

    {

    try {

        var tmp_folder_name = Folder.temp.fsName;

        var tmp_doc_name = tmp_folder_name + "\\doc.tmp";

        var doc_file = new File(file_path);

        if (!doc_file.copy(tmp_doc_name)) return null;

        doc_file = null;   

        doc_file = new File(tmp_doc_name);

        var s = "var file_path=" + doc_file.fsName.toSource();

        s = s.replace("(new String(", "");

        s = s.replace("))", ";");

        if (type == "xls")

            s = s + "\nvar fs=WScript.CreateObject('Scripting.FileSystemObject');\nvar s=\"\";\nwith (WScript.CreateObject('Excel.Application'))\n{\nWScript.CreateObject('WScript.Shell').AppActivate('Microsoft Excel');\nvar max_empy_row = 10;\nvar max_empy_clm = 10;\nwith (Application.Workbooks.Open(file_path)) \n{\nvar empy_row_cnt = 0;\nfor (var n = 1;; n++) \n{\nvar s1=\"\";\nvar empy_clm_cnt = 0;\nfor (var i = 1;; i++) \n    {\n    var val = ActiveSheet.Cells(n, i).Value;\n    if (val != undefined) { s1 = (s1 + val + \" \");  empy_clm_cnt = 0; }\nelse ++empy_clm_cnt;\nif (empy_clm_cnt > max_empy_clm) break;\n}\nif (s1) { s = s + s1 + \"\\n\"; empy_row_cnt = 0; }\nelse ++empy_row_cnt;\nif (empy_row_cnt > max_empy_row) break;\n}\nClose();\n}\nQuit();\n}\nvar f=fs.GetSpecialFolder(2).CreateTextFile(\"tmp.txt\",true,true);\nf.WriteLine(s);\nf.Close();\nfs.GetFile(fs.GetSpecialFolder(2).Path+\"\\\\tmp.js\").Delete();"

        else 

            return null;               

        var tmp_name = tmp_folder_name + "\\" + "tmp.js";

        var tmp_file = new File(tmp_name);

        tmp_file.encoding = "UTF8";

        tmp_file.open("w");

        if (tmp_file.error) return null;

        tmp_file.write(s);

        if (tmp_file.error) return null;

   

        tmp_file.close();

        tmp_file.execute();

        while(tmp_file.exists) { }

        doc_file.remove();

        return (tmp_folder_name+ "\\" + "tmp.txt");

        }

    catch (e) { alert(e); return null; }

    }  

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 18, 2018 Jul 18, 2018

Copy link to clipboard

Copied

Thanks! Do you think there would also be a solution for mac?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jul 18, 2018 Jul 18, 2018

Copy link to clipboard

Copied

LATEST

I can not say anything about the Mac

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 18, 2018 Jul 18, 2018

Copy link to clipboard

Copied

Upload your excel file to Dropbox for example so when we see its content it can be easier to write a script for you on Mac...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines