Highlighted

Script // Collect Items in Folders according to their names

Explorer ,
Mar 25, 2020

Copy link to clipboard

Copied

Hi

I am working on script to collect Items in folder has the same name but not work well 

 

for(var a = 1; a <= app.project.numItems; a++)
{
   if((app.project.item(a).name == app.project.item(a).name) && (app.project.item(a) instanceof CompItem)){
   app.project.item(a).parentFolder = app.project.item(a);
    }    
}

 

Test.jpg

Please,,, Help ;-}

Sorry for those strange answers my phone bugged out.

So I was telling that the folderID array is a storage and will have to loop through it:

var folderID = new Array();

for(var a = 1; a <= app.project.numItems; a++) { folderID.push(app.project.item(a).id) }

for(var i=0;i<folderID.length;i++){app.project.itemByID(folderID[i]).selected = true}

 

 

Topics

Error or problem, Scripting

Views

254

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

Script // Collect Items in Folders according to their names

Explorer ,
Mar 25, 2020

Copy link to clipboard

Copied

Hi

I am working on script to collect Items in folder has the same name but not work well 

 

for(var a = 1; a <= app.project.numItems; a++)
{
   if((app.project.item(a).name == app.project.item(a).name) && (app.project.item(a) instanceof CompItem)){
   app.project.item(a).parentFolder = app.project.item(a);
    }    
}

 

Test.jpg

Please,,, Help ;-}

Sorry for those strange answers my phone bugged out.

So I was telling that the folderID array is a storage and will have to loop through it:

var folderID = new Array();

for(var a = 1; a <= app.project.numItems; a++) { folderID.push(app.project.item(a).id) }

for(var i=0;i<folderID.length;i++){app.project.itemByID(folderID[i]).selected = true}

 

 

Topics

Error or problem, Scripting

Views

255

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
Explorer ,
Mar 25, 2020

Copy link to clipboard

Copied

Hye, so what I think is happening is that you are calling your items by their indexes and when you move those items into your folder all the indexes of the following items change. For instance if your folder's index is 4 and you move item n°1 into it the folder index become 3 andthe item's index is now 4... What you should do is running through your items as you currently do and instead of changing their folder's parent during that loop collect their ID into an array, then create a variable for your folder's ID and after you will be able to do a new loop in which you will call your items with project.itemByID(id) and change their parentfolder by targeting your folder through its id... The id unlike the index of an item won't change whatever you do in your project...

Hoping this will help you.
Regards
Joel

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
Reply
Loading...
Explorer ,
Mar 25, 2020

Copy link to clipboard

Copied

Thanks in advance, But it isn't working because ( app.project.itemByID ) works only with one ID and not Array

 

var folderID = new Array();
for(var a = 1; a <= app.project.numItems; a++)
{
folderID[folderID.length] = app.project.item(a).id;
}
app.project.itemByID[folderID].selected=true;

 

A simple test but it works only for one ID and not with Array  

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
Reply
Loading...
Explorer ,
Mar 25, 2020

Copy link to clipboard

Copied

Sorry for those strange answers my phone bugged out.

So I was telling that the folderID array is a storage and will have to loop through it:

var folderID = new Array();

for(var a = 1; a <= app.project.numItems; a++) { folderID.push(app.project.item(a).id) }

for(var i=0;i<folderID.length;i++){app.project.itemByID(folderID[i]).selected = true}

 

 

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
Reply
Loading...
Explorer ,
Mar 25, 2020

Copy link to clipboard

Copied

Oui ça marche Merci beaucoup pour votre temps et vos efforts :-))

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
Reply
Loading...
Explorer ,
Mar 25, 2020

Copy link to clipboard

Copied

try:



var folderID = new Array(); for(var a = 1; a <= app.project.numItems; a++) { folderID.push(app.project.item(a).id) }

for(var i=0;i}

Joel
sent from my iPhone


Envoyé de mon iPhone

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
Reply
Loading...
Explorer ,
Mar 25, 2020

Copy link to clipboard

Copied

try:



var folderID = new Array(); for(var a = 1; a <= app.project.numItems; a++) { folderID.push(app.project.item(a).id) }

for(var i=0;i}

Joel


Envoyé de mon iPhone

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
Reply
Loading...
Explorer ,
Mar 25, 2020

Copy link to clipboard

Copied

try:

var folderID = new Array(); for(var a = 1; a <= app.project.numItems; a++) { folderID.push(app.project.item(a).id) }

for(var i=0;i}

Joel

Envoyé de mon iPhone

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
Reply
Loading...