Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 883671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:37:48+00:00 2026-05-15T12:37:48+00:00

This following script almost does what I need. What I’m trying to do is

  • 0

This following script almost does what I need. What I’m trying to do is go through the opened documents, 139 of them, and save them as jpeg. However what it’s lacking is moving from one opened document to the other, so it saved the same image over 139 times. I assumed doc.close() would close the opened document and give a new one focus, but it doesn’t.

Here’s the code:

var destination = "C:/Documents and Settings/Administrator/My Documents/small images"
for(var i = 0; i < 5; i++)
{
    doc = documents[i];
    name_ = doc.name.substring(0, doc.name.indexOf('.'))
    saveForWebPNG(destination, name_);
    doc.close();
}

function saveForWebPNG(outputFolderStr, filename)
{
    var opts, file;
    opts = new ExportOptionsSaveForWeb();
    opts.format = SaveDocumentType.JPEG;
    opts.quality = 60;
    if (filename.length > 27) {
        file = new File(outputFolderStr + "/temp.jpg");
        activeDocument.exportDocument(file, ExportType.SAVEFORWEB, opts);
        file.rename(filename + ".jpg");
    }
    else {
        file = new File(outputFolderStr + "/" + filename + ".jpg");
        activeDocument.exportDocument(file, ExportType.SAVEFORWEB, opts);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T12:37:50+00:00Added an answer on May 15, 2026 at 12:37 pm

    According to the Adobe Photoshop CS2 JavaScript Scripting Guide it looks like you need to assign to the Application.activeDocument property to make that document the currently selected one for any actions. This makes sense since you’re using that property in the saveForWebPNG function without explicitly activating the document in the iterator in the first block. It might be as simple as the following change:

    for (var i = 0; i < 5; i++) {
      var doc = documents[i];
      app.activeDocument = doc; // Select that document.
      var name = doc.name.substring(0, doc.name.indexOf('.'))
      saveForWebPNG(destination, name);
      doc.close();
    }
    

    However, I don’t have a copy of Photoshop and haven’t verified this solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 497k
  • Answers 497k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can use this inside the storePair function to get… May 16, 2026 at 11:59 am
  • Editorial Team
    Editorial Team added an answer I think that defining type just using type somename won't… May 16, 2026 at 11:59 am
  • Editorial Team
    Editorial Team added an answer A common way is to assign the this you want… May 16, 2026 at 11:59 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Following is the table and script of this table. DECLARE @temp TABLE (PPId INT,
Using Python 2.6, I wrote a script in Windows XP. The script does the
I have the following code (almost an exact copy of the Chat server example
I am having a little bit of a trouble with the following: <script> $(document).ready(function()
I'm following this tutorial but it doesn't tell me how to run this jQuery
I found the following bash script in order to monitor cp progress. #!/bin/sh cp_p()
Consider the following XSLT script: <?xml version=1.0 encoding=ISO-8859-1?> <xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform> <xsl:output method=text encoding=iso-8859-1/>
I have the following function: <script type=text/javascript> function changeText(elem){ var oldHTML = document.getElementById(elem).innerHTML; var
I'm having some issues with a regular expression I'm creating. I need a regex
I'm no php expert (a mere beginner) but need some help! After hours searching

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.