• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

saveAs() opens the manual 'Save As' window, instead of using given arguments

New Here ,
Aug 07, 2019 Aug 07, 2019

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()

{

    ...

}

TOPICS
macOS , SDK

Views

625

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 08, 2019 Aug 08, 2019

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();

   

...

Votes

Translate

Translate
Adobe
Engaged ,
Aug 08, 2019 Aug 08, 2019

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)\\" );

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 08, 2019 Aug 08, 2019

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()

{

}

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 08, 2019 Aug 08, 2019

Copy link to clipboard

Copied

I'm not sure what changed but that works perfectly! Thanks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 08, 2019 Aug 08, 2019

Copy link to clipboard

Copied

LATEST

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.

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines