Add all open files to current project - Komodo 10

To add all open files to the current project, create this javascript macro in the toolbox. Then just execute it and all files will be added.

var views = ko.views.manager.topView.getDocumentViews(true);
var project = ko.projects.manager.currentProject;
if (project) {
    var part;
    var view;
    for (var i = 0; i < views.length; i++) {
        view = views[i];
        if (view.koDoc && view.koDoc.file) {
            part = project.createPartFromType('file');
            part.setStringAttribute('url', view.koDoc.file.URI);
            part.setStringAttribute('name', view.koDoc.file.baseName);
            ko.projects.addItem(part, project);
        }
    }
}

Props to Todd of ActiveState for the original, way back in 2009. Very minor mods to make it work with 10.

3 Likes