I'm trying to build this window that will help with organization. Basically its pulling all the folders from our projects folder and sorting their names and putting them into a dropdown list. The user would then select whatever project they are working on, enter their initials, add a short description, and then finally add a version number 001. I've got that all working seemingly fine in the script below. An example would be
XXXPROJECTNAME_XXXINTIALS_XXXDESCRIPTION_001.aep
/Volumes/Nacho/Multimedia/PROJECTS/ABC_123_Teaser/01_AE/DW/ABC_123_Teaser_DW_TEST_001.aep
we'd put that in an initialed folder inside our file structure, so /Volumes/Nacho/Multimedia/PROJECTS/ABC_123_Teaser/01_AE/DW
What I need some help with is checking to see if the folder exists already, and if it doesn't create the folder. I would always know where the folder is supposed to be.../Volumes/Nacho/Multimedia/PROJECTS/ABC_123_Teaser/01_AE/DW so I'd need a way to check it against another array of called folders. I feel like my logic is solid but coding skills are not. If the folder does exist we then need to check and see if the file name exists already in that folder. If it doesn't then save with the current name, but if it does exist then increment up from 001 to 002. Super bonus points if anyone can explain how to make the progress bar work while the list of folders is sorting. I've got about 125 folders for it sort through which takes about 7 seconds. The way I have it now, the progress bar does its thing for about 7 seconds and then the list sorts for another 7 seconds. For now the progress bar is the least of my issues.
Thanks
win=new Window("palette","AE Naming",[0,0,525,60],{resizeable:true,}); panel_1=win.add("panel",[5,5,525,57]); downlist_1=panel_1.add("dropdownlist",[5,25,185,46] ,["PROJECT LIST"]); edittext_1=panel_1.add("edittext",[190,25,250,45] ,"INITIALS",{readonly:0,noecho:0,borderless:0,multiline:0,enterKeySignalsOnChange:1}); edittext_2=panel_1.add("edittext",[255,25,380,45] ,"DESCRIPTION",{readonly:0,noecho:0,borderless:0,multiline:0,enterKeySignalsOnChange:1}); edittext_3=panel_1.add("edittext",[385,25,435,45] ,"001",{readonly:0,noecho:0,borderless:0,multiline:0,enterKeySignalsOnChange:1}); edittext_4=panel_1.add("edittext",[5,2,435,22] ,"FULL PATH NAME",{readonly:1,noecho:0,borderless:0,multiline:0,enterKeySignalsOnChange:1}); but_1=panel_1.add("button",[440,2,510,45],"SAVE"); progress_1=panel_1.add("progressbar", [5,0,510,5], 0, 100); win.center(); win.show(); but_1.onClick = function() { save(); } { var layerNameArray = new Array(); var myFolder = Folder("/Volumes/Nacho/Multimedia/PROJECTS/"); //Search for all Folders in the projects directory var myJPGFilesArray = myFolder.getFiles(function(f) {return f instanceof Folder}); if(myJPGFilesArray !== null){ for(var n=0; n<myJPGFilesArray.length;n++){ $.writeln(myJPGFilesArray[n].name); var test = myJPGFilesArray.toString().replace (new RegExp("%20", "g"), " "); //removes the %20 which are spaces layerNameArray.push(myJPGFilesArray[n].name); //adds Folders to the Array var sortMe = myJPGFilesArray.sort(); //Alphabetical sort //////////////PROGRESSBAR ESTIMATED TIME////////////// while(progress_1.value < progress_1.maxvalue) { // this is what causes the progress bar increase its progress progress_1.value++; $.sleep(35); //35 is about 7 seconds } $.writeln("Sorting Complete"); /////////////////////////////////////////////////////// downlist_1.add("item", sortMe[n].name); //Adds sorted Folders to the dropdownlist downlist_1.onChange = function () {(downlist_1.selection)} edittext_1.onChanging = function () {(edittext_1.text)} edittext_2.onChanging = function () {(edittext_2.text)} edittext_3.onChanging = function () {(edittext_3.text)} function save() { //var combined = ("Volumes/Nacho/Multimedia/PROJECTS/" + downlist_1.selection + "/01_AE/" + edittext_1.text + ""); var aa = downlist_1.selection.toString(); //PROJECT var bb = edittext_1.text.toString(); //INITIALS var cc = edittext_2.text.toString(); //DESCRIPTION var dd = edittext_3.text.toString(); //VERSION var ae = "/01_AE/"; //where intials fodler should live var slash = "/" var underscore = "_" var aep = ".aep" var macVolume = "/Volumes/Nacho/Multimedia/PROJECTS/"; var folderpath = macVolume+aa+ae+bb; var fullpath = macVolume+aa+ae+bb+slash+aa+underscore+bb+underscore+cc+underscore+dd+aep; edittext_4.text = fullpath; alert(folderpath); alert(fullpath); //Check to see if folder in folder path exists. if it does continue on. if it doesn't create a new folder. //Check to see if the file name.aep exitsts AKA fullpath. If it does exist then version up. 001 becomes 002. If not, just save as fullpath. } } } }
I know the solution is probably super simple, but I'm still very new to all of this both javascript and extendscript, so sometimes the simplest things are the easiest to overlook. Any help is much appreciated.
Thanks,