'ProjectItem.moveBin() not working correctly Extends Script (Adobe)

im currently developping a script with extends script which is a javascript-similar script language, that we use to automate tasks in Adobe's Softwares (here its premiere pro) Here is what my code is doing : -i import files from a folder in my computer -then i put them in a bin in my prpro project -and for each of this file i create a bin with the file and a sequence

My problem is that the last file is not move in a bin

here is my code

    root = app.project.rootItem
    newFilesPath = "C:/Path"
    newFilesBin = root.children[0]
    
    app.project.importFiles(newFilesPath, true, newFilesBin, false)
    
    app.project.save()
    
    newFilesBin = root.children[0]
    
    for(i=0; i<newFilesBin.children.numItems; i++){
        newFile = newFilesBin.children[0]
        name = newFile.name
        
        newBin = root.createBin(name)
        file.moveBin(newBin)
    }

So if i put several file in the path it doesnt move the last file instead of moving every files

Thanks for help



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source