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

To add progress bar in the script

Contributor ,
Aug 22, 2021 Aug 22, 2021

Copy link to clipboard

Copied

Hi All,

I want to add the progress bar in the below code which is UI functionality the part of my Folder Automation Script. As of now the main UI has been greyed out until the files move from the input folder to Output folder. Its not more interactive. Is it possible to add the progress bar until the copyfile function to complete the process?

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(1);
        }
    }

    //--------------------------------------------------------------------------------
    Stop_Button.onClick = function(){
        dialog.close(0);
        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]));
        }
    }
// Progress bar need to add for this function
    folderCreation();
    copyFiles();
    alert("Process Completed...")
}

 

TOPICS
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

correct answers 1 Correct answer

Community Expert , Aug 23, 2021 Aug 23, 2021

I provided above. For that case: 

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++;

Votes

Translate

Translate
Community Expert ,
Aug 23, 2021 Aug 23, 2021

Copy link to clipboard

Copied

File copying is very quick, usually just a few seconds. Are you sure you want a progress bar for that?

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
Contributor ,
Aug 23, 2021 Aug 23, 2021

Copy link to clipboard

Copied

Copy File function copy the files from multiple input folder and paste into respective output folder based on the CSV file. It take more time to complete, for that only I have looking for the progress bar to more interactive for the user instead of the main UI greyed out until the process done.

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 Expert ,
Aug 23, 2021 Aug 23, 2021

Copy link to clipboard

Copied

We would need to know what your folderCreation and copyFiles functions look like but generally a progressbar looks like this, where lengthOfFolders is the numerical value for the maximum number of files to process: 

var w = new Window('palette');
        w.pbar = w.add('progressbar', undefined, 0, lengthOfFolders);
        w.pbar.preferredSize.width = 300;
        w.show(); 
for each operation {
        w.pbar.value++;
}

 

Peter also covers progressbars extensively in Script UI for Dummies 

 

 

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
Contributor ,
Aug 23, 2021 Aug 23, 2021

Copy link to clipboard

Copied

Thanks brian,

Both folder creation and copy files function have processed based on CSV files. In CSV file, first column have with folder names and second column is sub folder name, and remaining each columns are link names for multiple language. 

In the input folder containing multiple sub folders with links, the script will match the link names in the CSV file with input folder copy the matched link and paste into the respective language folder.

still both the functions are work in progress and its quite confusing If I share the code.

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
Contributor ,
Aug 23, 2021 Aug 23, 2021

Copy link to clipboard

Copied

Is it possible to create the progress bar for functions instead of length?

 

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 Expert ,
Aug 23, 2021 Aug 23, 2021

Copy link to clipboard

Copied

You could have a length of 2, and update the progressbar value in betwee each function call. 

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
Contributor ,
Aug 23, 2021 Aug 23, 2021

Copy link to clipboard

Copied

what is progressbar value and how to update? Could you please explain in detail?

 

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 Expert ,
Aug 23, 2021 Aug 23, 2021

Copy link to clipboard

Copied

I provided above. For that case: 

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++;

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
Contributor ,
Aug 23, 2021 Aug 23, 2021

Copy link to clipboard

Copied

Thanks brian..

When I use this in my code it won't work...

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("Process Completed...")
}



 

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
Contributor ,
Aug 23, 2021 Aug 23, 2021

Copy link to clipboard

Copied

I tried with seperate progressbar function also its not working

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
Contributor ,
Aug 23, 2021 Aug 23, 2021

Copy link to clipboard

Copied

I have tried with seperate functions by using this thread...

https://community.adobe.com/t5/indesign/progress-bar-script-running/m-p/10461132

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
Contributor ,
Aug 23, 2021 Aug 23, 2021

Copy link to clipboard

Copied

Its working fine with Adobe Indesign and not for Photoshop. Is it correct?

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
New Here ,
Dec 01, 2022 Dec 01, 2022

Copy link to clipboard

Copied

LATEST

I have a script with a progress bar function with similar code to your first four lines and couldnt figure out how to get it to increment (im exporting multiple PDFs at the same time). I had no clue as to why it wasnt working but your `w.pbar.value++;` code line was the ticket, once I added that I'm getting the progress bar working prefectly.

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