Rodrigo Aben
Forum Replies Created
-
That solved beautifully, Filip. Thanks a lot!
-
Function .includes does not exist on extendscript
-
Actually it seems there’s no command ID for the smoother
-
Cant’t you just replace the “TEXT 01” by “TEXT” + thisLayer.index ?
-
BTW, I keep having no ideia of how .onActivate() works. Tryied different things but none of them returns anything.
-
Solved! Logical problem actually. I was adding the event listener to the window and not to the actual group. This is the proper way to write it:
var win = new Window ("dialog");
var maingroup = win.add ("panel {orientation: 'column'}");
add_row (maingroup);
var show_btn = win.add ("button", undefined, "Save presets");
show_btn.onClick = function () {
var txt = "";
for (var n = 0; n < maingroup.children.length; n++) {
txt += maingroup.children[n].edit.text + "\n";
}
alert ("Rows: \n" + txt);
}
win.show ();
function add_row (maingroup) {
var group = maingroup.add ("group");
group.statictext = group.add ("statictext", undefined, "Left-click +");
group.edit = group.add ("edittext", ["", "", 200, 20], "Click here and press any key");
group.plus = group.add ("button", undefined, "+");
group.plus.onClick = add_btn;
group.minus = group.add ("button", undefined, "-");
group.minus.onClick = minus_btn;
group.index = maingroup.children.length - 1;
group.addEventListener ("keydown", function (kd) {pressed (kd)});
function pressed (k) {
if(k.keyName === "Enter"){
group.edit.text = "Enter";
}
}
win.layout.layout (true);
}
function add_btn () {
add_row (maingroup);
}
function minus_btn () {
maingroup.remove (this.parent);
win.layout.layout (true);
} -
Seems like your comp is too small or preview quality is set to “half”. Maybe you could share your project so we can check it.
-
Sorry for bothering you too much, but I know I’ll face a whole new problem in case the “unique” file detected is part of a image sequence. Any insights on how to go about that?
-
Great solution, Filip! Thank you very much. I had no idea they would not be considered equal. Could you elaborate more on that?
BTW I would also like to avoid nesting functions and loops, but since folder.getFiles() only works one folder at a time, running this function seemed to me the simplest way of looping through all folders.
My full code below in case you see any room for improvement (and you probably will).
Thank you very much once again.
var myProj = app.project;//creates an array of all file's folders
var myAssetspath = [];
for (var i = 1; i <= myProj.numItems; i++) {
var filesPath = app.project.item(i).file.fsName.replace(app.project.item(i).name, "");
myAssetspath.push(filesPath);
}//this sorts the array
var mySortedFolders = myAssetspath.sort();
//removes duplicate folders
var myUniqueFolders = [];
for (var i = 0; i <= mySortedFolders.length; i++){
if(mySortedFolders[i] != mySortedFolders[i+1]){
myUniqueFolders.push(mySortedFolders[i]);
}
}// gets files from all unique folders and tests if they're already imported. If not, imports them
for (var i = 0; i < myUniqueFolders.length; i++){
// function ImportUniqueFiles(){
var folder = new Folder;
folder = Folder(myUniqueFolders[i]);var files = folder.getFiles();
// convert the list of File-Objects to a list of Strings of their Paths
files = files.map( function (f) { return f.absoluteURI });myImportedFiles = [];
for (var k = 1; k <= myProj.numItems; k++) {
var thisFile = app.project.item(k).file;
// many compItems don't have a file as source
if (thisFile !== null && thisFile !== undefined) {
myImportedFiles.push(thisFile.absoluteURI);
}
}
alert(myImportedFiles.length);importFiles(files);
function importFiles(files) {
for(var j = 0; j < files.length; j++) {
$.writeln(myImportedFiles.indexOf(files[j]));
if(myImportedFiles.indexOf(files[j]) == -1){
alert(files[j]);
app.project.importFile(new ImportOptions(files[j]));
}else{
alert("not unique");
}
}
}
} -
Turns out, Thomas was right. Sorry for the delay guys but your help has been amazing. These are the projects I’ve been able to create with it http://www.abenathar.com