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

Script // Collect Items in Folders according to their names

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

TOPICS
Error or problem , Scripting

Views

680

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

Explorer , Mar 25, 2020 Mar 25, 2020

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}

 

 

Votes

Translate

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

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

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

 

 

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

Copy link to clipboard

Copied

LATEST

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

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

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

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

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