Copy link to clipboard
Copied
My script doesn't saveAs() on its own; whenever saveAs() is called, it opens the regular Save As window as if I had simply pressed Cmd+Shift+S. The default save name is the original file name, rather than the name in the File I pass in. After this the Quality window also comes up, defaulting to the last used value.
Other answers don't indicate that there would be an issue with this. My code is based on this: Automate Batch Script - Convert filenames to text in Photoshop
How do I get it to use the arguments I pass into saveAs()without opening the regular window instead?
var sourceFolder = Folder.selectDialog( "Select source folder" );
var destFolder = Folder.selectDialog( "Select destination folder" );
var sourceFiles = sourceFolder.getFiles();
var saveOptions = new JPEGSaveOptions();
saveOptions.quality = 12;
for( var i = 0; i < sourceFiles.length ; ++i )
{
var doc = app.activeDocument = app.open( sourceFiles );
desktopize();
var saveFile = new File( destFolder.absoluteURI + "/" + doc.name );
doc.saveAs( saveFile, saveOptions, false, Extension.LOWERCASE );
doc.close( SaveOptions.DONOTSAVECHANGES );
}
function desktopize()
{
...
}
var orig_display_dialogs = app.displayDialogs;
app.displayDialogs = DialogModes.NO; // Set Dialogs off
var sourceFolder = Folder.selectDialog( "Select source folder" );
var destFolder = Folder.selectDialog( "Select destination folder" );
var sourceFiles = sourceFolder.getFiles();
var saveOptions = new JPEGSaveOptions();
saveOptions.quality = 12;
alert(sourceFiles.length);
for( var i = 0; i < sourceFiles.length ; ++i )
{
try {
var doc = app.activeDocument = app.open( sourceFiles );
desktopize();
...
Copy link to clipboard
Copied
Is that so?
var sourceFolder = Folder( "C:\\Users\\test\\Desktop\\Folder\\" );
var destFolder = Folder( "C:\\Users\\test\\Desktop\\Folder (2)\\" );
Copy link to clipboard
Copied
var orig_display_dialogs = app.displayDialogs;
app.displayDialogs = DialogModes.NO; // Set Dialogs off
var sourceFolder = Folder.selectDialog( "Select source folder" );
var destFolder = Folder.selectDialog( "Select destination folder" );
var sourceFiles = sourceFolder.getFiles();
var saveOptions = new JPEGSaveOptions();
saveOptions.quality = 12;
alert(sourceFiles.length);
for( var i = 0; i < sourceFiles.length ; ++i )
{
try {
var doc = app.activeDocument = app.open( sourceFiles );
desktopize();
var saveFile = new File( destFolder.absoluteURI + "/" + doc.name );
doc.saveAs( saveFile, saveOptions, false, Extension.LOWERCASE );
doc.close( SaveOptions.DONOTSAVECHANGES );
}
catch(e){}
}
app.displayDialogs = orig_display_dialogs; // Reset display dialogs
function desktopize()
{
}
Copy link to clipboard
Copied
I'm not sure what changed but that works perfectly! Thanks.
Copy link to clipboard
Copied
You should read both version of the code to see what is different and understand what the code does. The Code gets all file in a folder into a file list. Then uses Photoshop to open the files in the file list. Photoshop does not support all file type so the script will through an error if a file is the file list is one the is not supported. If a file is supported but is not an image file a document may not open. A action set may be loaded an script may run there will be no open document and the save as will fail. You original script has may issues.