How to open a file from file path using action
hi all,
how can we open the file from the file path using script or action.
please help me to get this.
Thank You
hi all,
how can we open the file from the file path using script or action.
please help me to get this.
Thank You
hi @Stephen Marsh
when i open the document i will retrieve some data from the active document and after retrieving i want to close the the document without saving.
Then you need to loop over the input files.
I'll post some code as an example...
EDIT: here is one way to open a folder of files and filter by file type and sort or reverse sort:
#target photoshop
// Set the input folder
var inputFolder = Folder.selectDialog("Please select the input folder:");
// Limit the input files, add or remove extensions as required
var fileList = inputFolder.getFiles(/\.(webp|tif|tiff|jpg|jpeg|psd|psb|png)$/i);
//fileList.sort().reverse();
fileList.sort();
var savedDisplayDialogs = app.displayDialogs;
app.displayDialogs = DialogModes.NO;
// Set the file processing counter
var fileCounter = 0;
// Forward loop over the input files
for (var i = 0; i < fileList.length; i++) {
open(fileList[i]);
/*
YOUR CODE HERE
*/
activeDocument.close(SaveOptions.DONOTSAVECHANGES);
fileCounter++;
}
app.displayDialogs = savedDisplayDialogs;
alert('Script completed!' + '\n' + fileCounter + ' files processed!');
This variation allows one to manually select one or more files to process (instead of processing a folder):
#target photoshop
(function () {
// Select the files
var selectFiles = File.openDialog("Please select the file or files:", Multiselect = true);
if (selectFiles === null) {
//alert("Script cancelled!");
return;
}
//selectFiles.sort().reverse();
selectFiles.sort();
var savedDisplayDialogs = app.displayDialogs;
app.displayDialogs = DialogModes.NO;
// Set the file processing counter
var fileCounter = 0;
// Forward loop over the input files
for (var i = 0; i < selectFiles.length; i++) {
open(selectFiles[i]);
/*
YOUR CODE HERE
*/
activeDocument.close(SaveOptions.DONOTSAVECHANGES);
fileCounter++;
}
app.displayDialogs = savedDisplayDialogs;
alert('Script completed!' + '\n' + fileCounter + ' files processed!');
})();
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.