Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Photoshop progressBar not working

Participant ,
Sep 08, 2021 Sep 08, 2021

Copy link to clipboard

Copied

Hi all,
Im trying to add the progress bar for the folderCreation() & copyFiles() functions. The progress bar working fine indesign not working in Photoshop. Is there anything to change in the code?

 

var AssetCSV_File;
var Handoffs_File;
var OutputFolder;
var FolderNames = [];
var SubFolderNames = [];
var Rules_styleMapping_head_csv;
var Replacement_Content_csv = [];
var ReadCSV_ColumnsHeads = [];
var printImages = [];
var screenImages = [];
var mainFlag;
var userName = $.getenv("USER");

//---------UI-Selection----------------------------------------------------------------------------------------------------
mainUI();
function mainUI(){
    var dialog = new Window("dialog"); 
        dialog.text = "Partner Asset Automator"; 
        dialog.orientation = "column"; 
        dialog.alignChildren = ["center","top"]; 
        dialog.spacing = 10; 
        dialog.margins = 16; 

    // PANEL1
    // ======
    var panel1 = dialog.add("panel", undefined, undefined, {name: "panel1"}); 
        panel1.text = "Asset Matrix CSV file"; 
        panel1.orientation = "column"; 
        panel1.alignChildren = ["left","top"]; 
        panel1.spacing = 10; 
        panel1.margins = 10; 

    // GROUP1
    // ======
    var group1 = panel1.add("group", undefined, {name: "group1"}); 
        group1.orientation = "row"; 
        group1.alignChildren = ["left","center"]; 
        group1.spacing = 10; 
        group1.margins = 0; 

    var editPath1 = group1.add('edittext {properties: {name: "edittext1", multiline: true, scrollable: true}}'); 
        editPath1.preferredSize.width = 350; 
        editPath1.preferredSize.height = 40; 

    var pathBrowse1 = group1.add("button", undefined, undefined, {name: "button1"}); 
        pathBrowse1.text = "Browse"; 

    // PANEL2
    // ======
    var panel2 = dialog.add("panel", undefined, undefined, {name: "panel2"}); 
        panel2.text = "WW_Handoffs Folder"; 
        panel2.orientation = "column"; 
        panel2.alignChildren = ["left","top"]; 
        panel2.spacing = 10; 
        panel2.margins = 10; 

    // GROUP2
    // ======
    var group2 = panel2.add("group", undefined, {name: "group2"}); 
        group2.orientation = "row"; 
        group2.alignChildren = ["left","center"]; 
        group2.spacing = 10; 
        group2.margins = 0; 

    var editPath2 = group2.add('edittext {properties: {name: "edittext2", multiline: true, scrollable: true}}'); 
        editPath2.preferredSize.width = 350; 
        editPath2.preferredSize.height = 40; 

    var pathBrowse2 = group2.add("button", undefined, undefined, {name: "button2"}); 
        pathBrowse2.text = "Browse"; 

    // PANEL3
    // ======
    var panel3 = dialog.add("panel", undefined, undefined, {name: "panel3"}); 
        panel3.text = "Output Folder"; 
        panel3.orientation = "column"; 
        panel3.alignChildren = ["left","top"]; 
        panel3.spacing = 10; 
        panel3.margins = 10; 

    // GROUP3
    // ======
    var group3 = panel3.add("group", undefined, {name: "group3"}); 
        group3.orientation = "row"; 
        group3.alignChildren = ["left","center"]; 
        group3.spacing = 10; 
        group3.margins = 0; 

    var editPath3 = group3.add('edittext {properties: {name: "edittext3",  multiline: true, scrollable: true}}'); 
        editPath3.preferredSize.width = 350; 
        editPath3.preferredSize.height = 40; 

    var pathBrowse3 = group3.add("button", undefined, undefined, {name: "button3"}); 
        pathBrowse3.text = "Browse"; 

    // GROUP4
    // ======
    var group4 = dialog.add("group", undefined, {name: "group4"}); 
        group4.orientation = "row"; 
        group4.alignChildren = ["left","center"]; 
        group4.spacing = 10; 
        group4.margins = 0; 

    var Start_Button = group4.add("button", undefined, undefined, {name: "button4"}); 
        Start_Button.text = "Start"; 

    var Stop_Button = group4.add("button", undefined, undefined, {name: "button5"}); 
        Stop_Button.text = "Cancel"; 

    //--------------------------------------------------------------------------------
    pathBrowse1.onClick = function(){
        AssetCSV_File = File.openDialog("Choose the Asset Matrix CSV File");
        if(AssetCSV_File != null){   
            editPath1.text = AssetCSV_File.fullName;
        }
    }
    //--------------------------------------------------------------------------------
    pathBrowse2.onClick = function(){
        Handoffs_Folder = Folder.selectDialog("Choose the WW_Handoffs Folder");
        if(Handoffs_Folder != null){   
            editPath2.text = Handoffs_Folder.fullName;
        }
    }
    //--------------------------------------------------------------------------------
    pathBrowse3.onClick = function(){
        OutputFolder = Folder.selectDialog("Choose the Output Folder");
        if(OutputFolder != null){   
            editPath3.text = OutputFolder.fullName;
        }
    }
    //--------------------------------------------------------------------------------
    Start_Button.onClick = function(){
        if(editPath1.text == "" || editPath2.text == "" || editPath3.text == ""){
            alert("Select the respective text fields and run the script...");
        }else{
            mainFlag = true;
            dialog.close();
        }
    }

    //--------------------------------------------------------------------------------
    Stop_Button.onClick = function(){
        dialog.close();
        alert("Process Cancelled...")
    }

    dialog.show();
}

//--------------------------------------------------------------------------------------
if(mainFlag == true){
    GettingInputFromCSV_UI(File(AssetCSV_File.fullName));
    if(Replacement_Content_csv.length>0){//Replacement_Content_csv // Rules_styleMapping_csv
        for(var a=0;a<Replacement_Content_csv.length;a++){
            FolderNames.push(String(Replacement_Content_csv[a][0]));
            SubFolderNames.push(String(Replacement_Content_csv[a][1]));
        }
    }
    var w = new Window('palette');
    w.pbar = w.add('progressbar', undefined, 0, 2);
    w.pbar.preferredSize.width = 300;
    w.show();
    folderCreation();
    w.pbar.value++;
    copyFiles();
    w.pbar.value++;
    alert("Hey " + userName+"!\r\rProcess Completed...")
}

 

 

TOPICS
Actions and scripting, macOS

Views

55

Likes

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
no replies

Have something to add?

Join the conversation