Copy link to clipboard
Copied
Hi, guys!
I am trying to create a script that is searching for some images in over 100 fodlers. Since it takes much time to complete it, it would be nice the user to have a progress bar. I read the documentation for indesign scripting and also searched for some pregress bar scripting examples over the web, but it still seems I am doing somethig wrong - my progress bar does not show value.
I tried to:
alert the value of the progress bar, just to see if it is changeing - it does;
tried to hide/show the progress bar, hoping that it will refresh and will change it's value - still doesn't;
tried to use window.update() method - still nothing;
I even set a value bigger than 0 in the beginning just to see if is shows something, but it stil doesn't work...
Can some more experienced than me (I am relatively new to scripting) have a look at the code and maybe point out my mistake?
var ArchCats = ArchFolder.getFiles()
var ProgBarWin = new Window("window","Progress",[0,0,500,150])
ProgBarWin.CatProgText = ProgBarWin.add("statictext",[50,20,450,40],"")
ProgBarWin.ProgText = ProgBarWin.add("statictext",[50,60,450,80],"")
ProgBarWin.progBar = ProgBarWin.add("progressbar",[50,100,450,130],0,ArchCats.length)
ProgBarWin.center()
ProgBarWin.show()
for (j=0;j<ArchCats.length;j++) {
ProgBarWin.CatProgText.text = "Searching cat "+j+" out of "+ArchCats.length
ProgBarWin.progBar.value = j+1
var ArchCat = ArchCats[j]
if (ArchCat instanceof Folder) {
var _sentFolders = ArchCat.getFiles("_sent")
if (_sentFolders.length<1){
alert("There is no _sent folder in catalog "+ArchCat.name+" It will not be processed")
continue;
}
else {
var ArchPages = _sentFolders[0].getFiles()
for (arp = 0;arp<ArchPages.length;arp++) {
ProgBarWin.ProgText.text = "Searching page "+arp+" out of "+ArchPages.length
DefineFoldersAndSearch(ArchPages[arp])
}
}
}
}
Thanks in advance,
Denis.
Copy link to clipboard
Copied
Hello,
Check the links below, they have example code that shows values
https://github.com/indiscripts/extendscript/blob/master/scriptui/ProgressBar.jsx
https://community.adobe.com/t5/indesign/progress-bar-script-running/td-p/10461132?page=1
Regards,
Mike
Copy link to clipboard
Copied
Try creating it as a palette instead of window.
var ProgBarWin = new Window("palette","Progress",[0,0,500,150])
Copy link to clipboard
Copied
Thank you for your response, Brian!
I tired, but it still doesn't work. The strange thing to me here is that if I "alert" the value of the progress bar, it changes, but the progress bad does not show it itself - stays "empty". Even if I set its starting value at somehing higher than 0, it doesn't change...
Copy link to clipboard
Copied
Hi, below script shows all files from specified folder,
maybe this is what you are looking for.
$.sleep(1000) - one second delay for demonstrates working
function get_files(path){
var folder = Folder(path).getFiles()
for(var i = 0; i < folder.length; i++){
if(File(folder[i]).constructor.name == 'Folder'){get_files(folder[i])}
else{ArchCats.push(File(folder[i]).fsName)}
}
}
var ArchCats = []
get_files('C:/Download/')
var winbar = new Window('palette','Progress')
winbar.pro = winbar.add('progressbar', undefined, 0, ArchCats.length)
winbar.pro.preferredSize = [300,20]
winbar.pro_text = ''
winbar.pro_static = winbar.add('statictext', [10, 10, 310, 25], winbar.pro_text)
winbar.pro_count = 1
winbar.show()
for(var i = 0; i < ArchCats.length; i++){
winbar.pro_static.text = ArchCats[i]
winbar.pro.value = winbar.pro_count
winbar.pro_count++
winbar.update()
$.sleep(1000)
}
winbar.close()
Copy link to clipboard
Copied
Thank you SychevKA!
I copied the part of your script where you create the window with the progressbar and used it in the place of mine script, but it also didn't work. I am starting to think the problem might be caused of the indesdign version I am using... Could it be?
Copy link to clipboard
Copied
Does my script work with your ID version? If yes, the problem is in your code.
Copy link to clipboard
Copied
After all there was a mistake in my script (in a function I defined the progress bar winddow again which caused it to look like it was not updated). I have a long way in front of me!...
Thank you for the help. 🙂