Created
October 24, 2023 20:25
-
-
Save MarshySwamp/8778d55f6fe5f18635fb4660dc485e58 to your computer and use it in GitHub Desktop.
Open Multiple Selected Files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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