Skip to content

Instantly share code, notes, and snippets.

@MarshySwamp
Created October 24, 2023 20:25
Show Gist options
  • Save MarshySwamp/8778d55f6fe5f18635fb4660dc485e58 to your computer and use it in GitHub Desktop.
Save MarshySwamp/8778d55f6fe5f18635fb4660dc485e58 to your computer and use it in GitHub Desktop.
Open Multiple Selected Files
var selectFile = File.openDialog("Please select the file/s:", Multiselect = true);
for (var i = 0; i < selectFile.length; i++) {
var openFiles = app.open(File(selectFile[i]));
}
// or
var aFile = selectFile(true);
for (var i = 0; i < aFile.length; i++) {
open(File(aFile[i]));
}
////// select file //////
function selectFile(multi) {
if (multi === true) { var theString = "Please select the files:" }
else { var theString = "Please select one file" }
if ($.os.search(/windows/i) != -1) { var theFiles = File.openDialog(theString, '*.jpg;*.tif;*.psd;*.png', multi) }
else { var theFiles = File.openDialog(theString, getFiles, multi) }
////// filter files for mac //////
function getFiles(theFile) {
if (theFile.name.match(/\.(jpg|tif|psd|png)$/i) || theFile.constructor.name == "Folder") {
return true;
}
}
return theFiles
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment