Skip to main content
New Participant
July 26, 2025
Answered

UXP: getItems() returns ProjectItems — how to access subfolders?

  • July 26, 2025
  • 1 reply
  • 154 views

hi,

I'm trying to work with folders/bins using UXP, but I'm having trouble navigating through the folder hierarchy and getting references to subfolders.

Calling getRootItem() gives me a FolderItem{}, which is expected.

However, when I try to go one level deeper using getItems(), I only get ProjectItem objects in return — even if the actual items are folders. Since I can only call getItems() on a FolderItem, I'm stuck. How can I access the contents of a subfolder?

root
├── folder1
├── folder2
│      ├── subfolder1
│      └── subfolder2
│               ├── movieclip1.mov
│               └── movieclip2.mov

How can I get the contents of something like subfolder2?

Thanks a lot!
Julian

---
UXP Developer Tools: 2.1.0.30
PPro Version 25.6.0 BETA (Build 9)

 

Correct answer Ben Insler

Hi @Julian5D97 ,

 

ProjectItems are somewhat generic objects that simply provide the starting point to accessing the specific attributes of each type of item.  For example, ClipProjectItems can do things that FolderItems can't, and vice versa.  So when you use .getItems() to get the contents of a folder, all contained items get listed as ProjectItems, and then you must inspect these items to step into further functionality for each one.  We currently use .cast() for this.

 

In your case, let's say you want to traverse your project folder tree.  Project.getRootItem() returns the root of the project as a FolderItem, and thus, .getItems() will work to return a list of ProjectItems found in the root.  To then determine which ProjectItems in the returned list are folders, you must try to cast each one to a FolderItem - if the cast is successful, the ProjectItem is a FolderItem; if the cast fails, the ProjectItem is not a FolderItem (note, this does not indicate what type of item the ProjectItem is, this only indicates that it is not a FolderItem!).

 

For the ProjectItems that have been successfully cast to FolderItems (assuming you save them to a variable), the .getItems() method will now also be available on those cast FolderItem objects for you to continue traversing the tree.


To perform the cast, use the following: 

const myFolderItem = require("premierepro").FolderItem.cast(myProjectItem);
You can also check out how this has been implemented in our sample panels.
 
Best,
 
Ben

1 reply

Ben InslerCommunity ManagerCorrect answer
Community Manager
July 28, 2025

Hi @Julian5D97 ,

 

ProjectItems are somewhat generic objects that simply provide the starting point to accessing the specific attributes of each type of item.  For example, ClipProjectItems can do things that FolderItems can't, and vice versa.  So when you use .getItems() to get the contents of a folder, all contained items get listed as ProjectItems, and then you must inspect these items to step into further functionality for each one.  We currently use .cast() for this.

 

In your case, let's say you want to traverse your project folder tree.  Project.getRootItem() returns the root of the project as a FolderItem, and thus, .getItems() will work to return a list of ProjectItems found in the root.  To then determine which ProjectItems in the returned list are folders, you must try to cast each one to a FolderItem - if the cast is successful, the ProjectItem is a FolderItem; if the cast fails, the ProjectItem is not a FolderItem (note, this does not indicate what type of item the ProjectItem is, this only indicates that it is not a FolderItem!).

 

For the ProjectItems that have been successfully cast to FolderItems (assuming you save them to a variable), the .getItems() method will now also be available on those cast FolderItem objects for you to continue traversing the tree.


To perform the cast, use the following: 

const myFolderItem = require("premierepro").FolderItem.cast(myProjectItem);
You can also check out how this has been implemented in our sample panels.
 
Best,
 
Ben