You can use the chooseFromList command in your JavaScript instead of the "Choose from List" action and another "Run JavaScript" action.
You an use .map() to loop from the selected items.
Here's the script:
function run(input, parameters) {
thisApp = Application.currentApplication()
thisApp.includeStandardAdditions = true
var destFolder = input[0];// the destination folder
var array = ["PDF", "LINKS", "PERSMAP", "SCHUIMKARTON", "INSPIRATIE"];
theseNames = thisApp.chooseFromList(array, {withPrompt: 'Which folders to create?', multipleSelectionsAllowed:true});
if (theseNames == false) {return}; // exit this script because user cancelled
// (for each selected name then create the folder if this name does not already exists in the destination folder), return path of these sub-folders to the next action
return theseNames.map(function(thisName) {
newFolder = destFolder + "/" + thisName + "/";// concatenation of the destination folder and an item in theseNames
$.NSFileManager.defaultManager.createDirectoryAtPathWithIntermediateDirectoriesAttributesError(newFolder,false,$(), $());
return newFolder;
});
}
Update
To create some subfolders within the new folder, use conditions (if name equal some name), like this:
function run(input, parameters) {
thisApp = Application.currentApplication()
thisApp.includeStandardAdditions = true
var destFolder = input[0];// the destination folder
var array = ["PDF", "LINKS", "PERSMAP", "SCHUIMKARTON", "INSPIRATIE"];
theseNames = thisApp.chooseFromList(array, {withPrompt: 'Which folders to create?', multipleSelectionsAllowed:true});
if (theseNames == false) {return}; // exit this script because user cancelled
f_m = $.NSFileManager.defaultManager;
// (for each selected name then create the folder if this name does not already exists in the destination folder), return path of these sub-folders to the next action
return theseNames.map(function(thisName) {
newFolder = destFolder + "/" + thisName + "/";// concatenation of the destination folder and an item in theseNames
f_m.createDirectoryAtPathWithIntermediateDirectoriesAttributesError(newFolder,false,$(), $());
if (thisName == "PDF") { // create folder1 and folder2 in the PDF folder
f_m.createDirectoryAtPathWithIntermediateDirectoriesAttributesError(newFolder + "folder1",false,$(), $());
f_m.createDirectoryAtPathWithIntermediateDirectoriesAttributesError(newFolder + "folder2",false,$(), $());
}
if (thisName == "INSPIRATIE") { // create folderX in the INSPIRATIE folder
f_m.createDirectoryAtPathWithIntermediateDirectoriesAttributesError(newFolder + "folderX",false,$(), $());
}
return newFolder;
});
}