HELP:script that iterates through all opened documents and rezise them to match the biggest one.

Hi,
I'm making a batch processing action and I really need a script that iterates through all open documents, finds the one with the biggest image size and then iterates one more time to change the rest of the documents to the same image size dimensions. At the end all documents must share identical image size.  I'll really  appreciate if someone can put a quick script for doing this. Thank you !

I think should do…
#target photoshop
if (documents.length > 1) {
     var smallest = 1000000; // Set beyond any size you may be expecting this should do?
     for (var a = 0; a < documents.length; a++) {
          smallest = Math.min(smallest,documents[a].width.as('px'));
     for (var b = 0; b < documents.length; b++) {
          if (documents[b].width.as('px') != smallest) {
               app.activeDocument = documents[b];
               var newWidth = new UnitValue(smallest, 'px');
               documents[b].resizeImage(newWidth,undefined,undefined,ResampleMethod.BICUBICSMOOTHER);
}else{
     alert("NOT enough docs to resize?");

Similar Messages

  • How do i tab through all open documents

    Alt + Tab on a windows machine will tab through all open windows and documents.  Command + Tab on my IMAC will only tab through the open applications.  Is there a way I can set up the IMAC to work like to windows machine in this case?

    four finger swipe upwards will show you everything thats open. its not the same as on a pc where it shows each program in a rotating type of display... but it does show each program and the windows within that program that are open.

  • Now that I have upgraded to Yosemite I have a problem when I scan documents.  Before, a window showed today's activity.  Now I have to search through all my documents and hope to find what I just scanned.

    Now that I have upgraded to Yosemite I have a problem when I scan documents.  Formerly, a window showed today's activity.  Now, I have to search through all the documents in my history to find what I just scanned.  Sometimes I can't even find the doc.

    Most scan apps have a setting whereas, your scan(s) can go directly to your desktop.  No need to "hunt" for scanned docs.

  • Loop through all open documents not performing some actions

    I have a loop that imports XML, then Exports each page individually, then has a SaveAs dialog for the indd, then closes the active document.
    The import XML works, the SaveAs works, and the close works but the loop skips over the PDF part. Is it because I need to define myCounter in the for loop within the ExportPDF function? I just included the part from Choose XML to the end of ExportPDF.
    //choose XML
    var FilterXML = "XML File: *.xml";
    var myXML = File.openDialog("Choose XML File", FilterXML);
    //loop for each action below
    for(myDocumentCounter = app.documents.length; myDocumentCounter > 0; myDocumentCounter--){
    //import XML
    app.activeDocument.importXML(myXML);
    //PDF by page to settings; preset must be "dailies_x1a"
    function myExportPages(myFolder){
    var myPageName, myFilePath, myFile;
    var myDocument = app.activeDocument;
    var myDocumentName = myDocument.name;
    var myBaseName = myBaseNameField.editContents;
    for(var myCounter = 0; myCounter < myDocument.pages.length; myCounter++){
    myPageName = myDocument.pages.item(myCounter).name;
    app.pdfExportPreferences.pageRange = myPageName;
    //The name of the exported files will be the base name + the page name + ".pdf".
    //If the page name contains a colon (as it will if the document contains sections), then remove the colon.
    var myRegExp = new RegExp(":","gi");
    myPageName = myPageName.replace(myRegExp, "_");
    myFilePath = myFolder + "/" + myBaseName + "_" + myPageName + ".pdf";
    myFile = new File(myFilePath);
    myDocument.exportFile(ExportFormat.pdfType, myFile, false, "dailies_x1a");

    Nevermind, I found my error. Code should read...
    for(myDocumentCounter = app.documents.length; myDocumentCounter > 0; myDocumentCounter--){
    if(app.documents.length != 0){
    var myFolder = Folder.selectDialog ("Choose a Folder to Save the PDFs");
    if(myFolder != null){
    myExportPages(myFolder);
    else{
    alert("Please open a document and try again.");
    function myExportPages(myFolder){
    var myPageName, myFilePath, myFile;
    var myDocument = app.activeDocument;
    var myDocumentName = myDocument.name;
    var myDialog = app.dialogs.add();
    with(myDialog.dialogColumns.add().dialogRows.add()){
    staticTexts.add({staticLabel:"Please Modify the Base Name if Necissary:"});
    var myBaseNameField = textEditboxes.add({editContents:myDocumentName,
    minWidth:160});
    var myResult = myDialog.show({name:"ExportPages"});
    if(myResult == true){
    var myBaseName = myBaseNameField.editContents;
    //Remove the dialog box from memory.
    myDialog.destroy();
    for(var myCounter = 0; myCounter < myDocument.pages.length;
    myCounter++){
    myPageName = myDocument.pages.item(myCounter).name;
    app.pdfExportPreferences.pageRange = myPageName;
    //The name of the exported files will be the base name + the
    //page name + ".pdf".
    //If the page name contains a colon (as it will if the
    //document contains sections),
    //then remove the colon.
    var myRegExp = new RegExp(":","gi");
    myPageName = myPageName.replace(myRegExp, "_");
    myFilePath = myFolder + "/" + myBaseName + "_" + myPageName + ".pdf";
    myFile = new File(myFilePath);
    myDocument.exportFile(ExportFormat.pdfType, myFile, false, "dailies_x1a");
    else{
    myDialog.destroy();

  • Find all open windows and close them

    Hi,
    I'm writing an application that creates a new thread. This thread loads an other application from the filesystem and invokes the main method.
    When the thread loads an application that opens a frame, my application can stop the thread, but the frame stays open.
    Is there a way that my application can detect if the thread has opened a frame and if there are opened frames that it can close them?

    Well, tht's an idea, but my problem is, that my thread can start any aplication by invoking it's main-method.
    That means that even my Thread doesn't know which and how many frames it has opened or at least I don't know how I could get a list of all openened frames :-(
    A little bit code:
    /*Class classToRun is given to the Thread at it's initalisation and already loaded
    by a custom ClassLoader, that loads any .class file from a given location*/
    classToRun.getMethod("main", new Class[]{String[].class}).invoke(null, new String[]);

  • Can I save all open windows, and reload them later?

    Hi,
    I work on different projects using different applications.
    Say I am working on recording, and editing an audio. I have Quicktime open, finder(showing files) and GarageBand. Is there anyway I can save the current open windows, so at a later date I can just resume where I left off, rather then having to reopen the finder window, and the applications. It's almost liek I want a snapshot of what's open.
    Is there a 3rd party program that does this?
    Thanks.

    Thanks for the answer, but I would really like to close the apps. I may not return to the project for weeks. That's why I would love if a program could save the current open apps, so when I return to my project. I run this program and boom all of my Finders, and applications are restored the way I left them. It saves me time.

  • Looking for PS Script to Save and Close All Open Documents

    I used ACR and CS5 to process my Nikon D3 NEF files. I would like a script that would save all open documents (witin PS) with the highest possible quality (12). I've found several scripts that will close all open documents with save but cannot figure out how to implement a save script.
    For example, I may have 20 converted .jpeg files open. I would like to run a script to save & close all open documents.
    Is it possible? Can someone post an example working script?

    Take a look at the image processor, under the scripts menu.
    MTSTUNER

  • How to get all open document?

    I want to replace some elements through all open documents in
    dreamweaver.
    eg. replace <b> to <strong> and </b> to
    </strong>
    I know i can do this by using "replacing all", but i want to
    replace a lot of things together. it's boring to replace them one
    by one :P
    Anyone know how to make it?
    Thank you for your help! ^^

    "xsiren" <[email protected]> wrote in
    message
    news:f1v1o5$333$[email protected]..
    > the "dreamweaver.getDocumentList()" is only for get all
    the list of open
    > documens, istn't it?
    > i tried to alert the value of it, and it show something
    like
    > "file://D:\develop\1.html" "file://D:\develop\2.html"
    And then you are supposed to get the DOM out of the url,
    passing it as an
    argument to dreamweaver.getDocumentDOM()
    Massimo Foti, web-programmer for hire
    Tools for ColdFusion and Dreamweaver developers:
    http://www.massimocorner.com

  • Iterate through all documents

    Hi,
    We have a container which contains *1 million* documents, each of which has size 5K. Container type is wholedocument. We need to iterate through all document regualrly using container.getAllDocuments(containerTxn, DBXML_LAZY_DOCS | DBXML_NO_INDEX_NODES). For each document, we will perform a xpath query in xml document in memory.
    The problem here is about whether we should use transaction. If transaction is used, getAllDocuments will report "Lock table is out of available lock entries" error when it scan about 9383 ducuments. Here are lock setting:
    envp->set_lk_max_lockers(6000);
    envp->set_lk_max_locks(6000);
    envp->set_lk_max_objects(8000);
    We have 1 million documents, it is impossible to set lock object to 1 million.
    My questions:
    (1) Is this normal? If so, why performing a dbxml query on the container doesn't cause such an error. I believe dbxml query has to iterate all of documents too.
    (2) Is it possible to use a seek position for getAllDocuments? Thus we can commit transaction every iterating 1000 documents, and then continue the iteration from the last seek position.
    (3) if we don't use transaction to call getAllDocuments, what possible problems will happen? Other threads are using transaction to read/update the documents.
    Thanks.
    -Yuan

    Yuan,
    The quickest thing to try is to add the flag DB_READ_COMMITTED to getAllDocuments(). That may reduce the number of locks you need. While you may not be able to set the various lock parameters to 1 million, you should set them much larger than you have now (e.g. 50k - 100k) for this sort of operation.
    Not using transactions at all can lead to inconsistent data mostly related to index consistency with document content. Depending on the nature of your updates it may be safe. You could get stray exceptions but nothing should crash. E.g. if you are only adding/removing documents you are probably safe without transactions; although you might iterate to a document that's been removed so you'll see an exception which would have to be ignored. I'm not 100% certain this will work well but if you can test it in a high-update environment and see no issues that will tell you. The read side will not interfere with the updates.
    As for "seeking" if you look under the covers getAllDocuments() is really just a wrapper for an index lookup on the name index. The XmlIndexLookup API is quite flexible in terms of returning ranges. If you want to look into returning ranges of documents, do this:
    1. look at the code in XmlContainer.cpp in the function "getDocs()". It uses XmlIndexLookup to perform the operation.
    2. look at the XmlIndexLookup API to figure out how to turn the lookup into a range lookup vs looking up ALL items in the index
    Using XmlIndexLookup and tracking the name of your last-used document you can easily ask for all documents "higher" than that one. Further, if you know how your documents are named lexicographically you can give it a maximum as well if you wanted, but given that you can set your XmlQueryContext to be lazy you can simply iterate N times to get the next N documents without paying a penalty retrieving any documents you don't need.
    For the sort of thing you are doing I highly recommend using XmlIndexLookup directly (with or without transactions) to get the flexibility you need. XmlContainer::getAllDocuments() is merely a "convenience" layer on that class.
    Regards,
    George

  • Applescript to save all open documents?

    Hello,
    When I close Numbers, I usually have about 15 documents with changes and I have to go through "Do you want to save changes" for all of them.
    I've googled and tried, without success, to get a script that saves all open documents, except for untitled ones.
    Is there anyone who know such a script?
    Fred

    Here is a revised version.
    The problem was due to the fact that the script save and close the documents.
    When I tested it, it was only saving them.
    --[SCRIPT save&backup4iWork]
    Enregistrer le script en tant que Script : save&zip4iWork.scpt
    déplacer le fichier ainsi créé dans le dossier
    <VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:
    Aller au menu Scripts puis choisir “save&zip4iWork”
    Tous les documents iWork ouverts, ayant déjà été enregistrés puis modifiés seront enregistrés et fermés.
    Si la propriété avecSauvegarde a la valeur true, une copie horodatée de chaque fichier est créée.
    Si le document principal est de type paquet, la copie est compressée (zip).
    --=====
    L’aide du Finder explique:
    L’Utilitaire AppleScript permet d’activer le Menu des scripts :
    Ouvrez l’Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
    Cochez la case “Afficher le menu des scripts dans la barre de menus”.
    Sous 10.6.x,
    aller dans le panneau “Général” du dialogue Préférences de l’Éditeur Applescript
    puis cocher la case “Afficher le menu des scripts dans la barre des menus”.
    --=====
    Save the script as a Script: save&zip4iWork.scpt
    Move the newly created file into the folder:
    <startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
    Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
    Go to the Scripts Menu then choose “save&zip4iWork”
    Every open iWork document already saved then edited will be saved and closed.
    --=====
    The Finder’s Help explains:
    To make the Script menu appear:
    Open the AppleScript utility located in Applications/AppleScript.
    Select the “Show Script Menu in menu bar” checkbox.
    Under 10.6.x,
    go to the General panel of AppleScript Editor’s Preferences dialog box
    and check the “Show Script menu in menu bar” option.
    if the property avecSauvegarde is set to true, a dateTime stamped copy of each document is also created.
    It's zipped if the main document is a package.
    Yvan KOENIG
    based on my AutoSave script.
    2011/06/09
    --=====
    property avecSauvegarde : false
    true = keep a dateTime stamped copy
    false = don't keep a dateTime stamped copy
    property saveKeynote : false
    property saveNumbers : true
    property savePages : false
    --=====
    on run
              if savePages then my auto4PKN("Pages")
              if saveKeynote then my auto4PKN("Keynote")
              if saveNumbers then my auto4PKN("Numbers")
    end run
    --=====
    on auto4PKN(theApp)
              local titres, theDocs, aDoc, aPath
              tell application "System Events" to set titres to title of processes
              if theApp is in titres then
                        tell application theApp
    As we close the documents, we must store the list of docs in a variable
    or scan the list from the end which would require an index !
                                  set theDocs to every document
                                  repeat with aDoc in theDocs
                                            if modified of aDoc then
                                                      set aPath to path of aDoc
                                                      try
                                                                set aPath to aPath as text
                                                      on error
    Here if the document was never saved before
                                                                set aPath to ""
                                                      end try
                                                      if aPath is not "" then
    Save and close documents which were already saved once
                                                                close aDoc with saving
                                                                if avecSauvegarde then my zipIt(aPath)
                                                      end if -- aPath
                                            end if -- modified
                                  end repeat
                        end tell -- theApp
              end if -- theApp is…
    end auto4PKN
    --=====
    on zipIt(fichier) (* fichier is an HFS path*)
              local Nom, ext, dossier, isPackage, nomAvecDateHeure, source, dest
              set fichier to "" & fichier
              tell application "System Events" to tell disk item fichier
                        set Nom to name
                        set ext to name extension
                        set dossier to path of container
                        set isPackage to package folder
              end tell
              set source to quoted form of POSIX path of fichier
              set nomAvecDateHeure to (text 1 thru -(2 + (count of ext)) of Nom) & (do shell script "date +_%Y%m%d-%H%M%S.") & ext
              if isPackage then
                        set dest to quoted form of POSIX path of (dossier & nomAvecDateHeure & ".zip")
                        do shell script "ditto -ck " & source & " " & dest
              else
                        set dest to quoted form of POSIX path of (dossier & nomAvecDateHeure)
                        do shell script "cp " & source & " " & dest
              end if
    end zipIt
    --=====
    --[SCRIPT]
    --{code}
    I included your specific requirements.
    Yvan KOENIG (VALLAURIS, France) jeudi 9 juin 2011 18:03:20
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.7
    Please : Search for questions similar to your own before submitting them to the community
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !

  • On my mac i accidentally deleted all my documents and now i cant play my songs from itunes but can on my phone and my photos are there but when i open them they are not but i can see some on my iphone but not all. How do i get these back or are they lost?

    I accidentally dleted all my documents and emptyed the trash can. I can play my music on my iphone but not through my mac because it says it cant locate the file/original and my photos are on my computer but when i double click to open them they come up with an ! however some of the photos are on my iphone but just the ones i took using the camera function. Can i get this stuff back or it lost forever.....

    At the AT&amp;T store. Tried using iCloud but only 120 songs were transferred and when I access my iTunes account now it only shows 120 and not the 450 anymore that I purchased on my old phone. Tried to sync again from the phone to iTunes and it still not working.
    I purchased everything under the same apple ID account I called apple support and spent almost 2 hours with tech support for assistance and we got disconected and they never called me back.
    I'm at the point where I'm about to never purchase anything anymore from apple go to another company retrieve every single charge made on my bank account from iTunes and file a law suit against the company. It's being a week that I called for assistance and no one called me back to help me with this matter even after I responded a survey with a complaint about not getting a resolution to my problem.
    If you could please help me I will appreciate, I'm out of the country now and can't stay on the phone for a long time.
    I need to sell my old phone but as right now besides all my bank statements the old phone is the only evidence that I purchased the songs.

  • Command in Java for "all opened documents"

    I have a script that needs modification. Thank you all in the forum for helping me design this script from start btw!
    Anyway, this is the script.
    var myDoc = app.activeDocument;
    app.findGrepPreferences = app.changeGrepPreferences = null;
    // Change "Condition 1" to name of your condition
    myConditionList = app.activeDocument.conditions.everyItem().getElements();
    for (i=myConditionList.length-1; i>=0; i--)
        if (myConditionList[i].visible == false)
            myConditionList[i].visible = true;
            app.findGrepPreferences.appliedConditions = [myConditionList[i].name] ;
            app.findGrepPreferences.findWhat = ".+";
            myDoc.changeGrep();
            app.activeDocument.conditions.item(myConditionList[i].name).remove();
    I'm looking for a variable that can apply for "all" opened documents rather than the active one only. I'm having difficulty finding the right command.
    BTW, the script removes all hidden text and objects.

    Programming has never been my strong side. Never understood it properly and probably never will =(. But thank you solving it. The code "JUMO_OVER" wrote, worked like charm. No need to execute the script 10x for 10 documents.
    Pardon me for giving you guys more out headaches, I have two additional scripts that needs revision for the same purpose as above, i.e. able to exceute the scrip for all opened docs, saved or unsaved. I would really appreciated if you guys could help me convert them. I tried it do it on my own own, but I can't get it working... =(
    Delete Empty Frames in active doc
    var myStories = app.activeDocument.stories.everyItem().getElements();
    for (i = myStories.length - 1; i >= 0; i--)
        var myTextFrames = myStories[i].textContainers;
        for (j = myTextFrames.length - 1; j >= 0; j--)
            if (myTextFrames[j].contents == "")
                myTextFrames[j].remove();
    Delete Empty Pages in active doc
    app.doScript("main()", ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT,"Remove  Blank Pages");
    function main () {
        if (app.documents.length === 0) {
            alert ("Please open a document.");
            return;
        app.scriptPreferences.enableRedraw = false;
        removeBlankPages (app.Documents);
        app.scriptPreferences.enableRedraw = true;
        function removeBlankPages (doc) {
            var pages = doc.pages.everyItem().getElements().slice(0);
            var i = pages.length;
            while (i-- >1) { // a bit quicker here
                !pages[i].allPageItems.length && pages[i].remove ();
            !pages[i].allPageItems.length && pages[i] != doc.pages[-1] && pages[i].remove ()
    BTW, I didn't write them. So they may look quirky in your eyes.

  • Iterate through all dynamic text variables

    Hello,
    I'd like to be able to iterate through all of the dynamic
    text variables in my flash movie, and I'd like it so that if I add
    new text to this movie, it will show up in the iteration.
    Essentially, I want to do something like this:
    for (i in _root) {
    trace(i);
    While this seems to print out all the variables in root, it
    prints more than just the dynamic text variables, and also doesn't
    iterate down through various objects to find the dynamic text
    variable.
    Is there any way I can accomplish this in action script?
    Thanks!

    Great! That code helps me a lot.
    There are still two weird issues.
    1) the test for tl[obj].text seems to always turn out to be
    false. However, if I trace the value of text, I'll see the text.
    Example:
    trace(tl[obj].text); // This will display the value in the
    text field
    if (tl[obj].text) // This is always returning false.
    Any ideas?
    The 2nd issue might be more difficult - some of my text
    objects don't appear until later in the movie (i.e. frame 10). It
    sort of looks like this looping doesn't see objects that appear in
    the future. Do I need to advance the frame 1 by 1 and repeat this
    looping process until the text appears? Maybe instead I can always
    have the text in the first frame, but have it be invisible or
    something?

  • Sales document report for all open documents

    hi i need the code for sales document report for all open documents is sd
    ...      can anyone help me out.
                                     thanks in advance

    Try transaction VA05. In that choose "Open Orders" along with other selection criteria.
    If you want the Open sales order qty in output and its not displayed, do the following.
    Sales -> System modification -> create new fields ( without condition technique) -> New fields for lists.
    You can change V05TZZMO and structure VBMTVZ from there or use SE38 / SE11.
    For both you'll need an object registration in OSS.
    Hope this helps.
    Thanks,
    Balaji

  • Iterate through all the records in a table using Java API

    Hi All,
    What is the easiest way to iterate through all the records in a given table using Java API? I cannot find any methods that will return all records in a table and the only way I can use is to perform a free form search with a condition that is always true. The code works but is pretty ugly. Is there an alternative to this approach?
    Thanks!
    Kenny

    Hi Kenny,
    You can construct a new Search object with your table's code name, a new ResultSetDefinition object for your table and just execute this search using the GetResultSet method of CatalogData.
    Please look at the following code:
    Search search = new Search(<code name of your table>);
    ResultSetDefinition rsd = new ResultSetDefinition(<code name of your table>);
    rsd.AddField<code name of a field>);
    rsd.AddField(<code name of a field>);
    String sortField = <code name of your sort field>;
    boolean sortAscending = true;
    int page = 0; //page number
    A2iResultSet rs = <your CatalogData object>.GetResultSet(search, rsd, sortField, sortAscending, page);
    for (int i = 0; i < rs.GetRecordCount(); i++)
        Value fieldValue = rs.GetValueAt(i, <code name of a field>);
    Hope this helps,
    Nir
    PS - I really recommend you to start using the new API, as it is much more efficient and straight-forward.

Maybe you are looking for

  • Using jar to change functionality of forms text item: possible?

    Hii..I'm using Oracle Forms 10g Rel 1 and DB 10g with AS 10g. The requirement is to have a text field that is able to format text like word processor (e.g. MS Word) and must support image drag drop facility. To facilitate all these, I have written a

  • BAPI's  in ECC 6.0

    Hi,    What are the corresponding BAPI's for these transaction in ECC 6.0 MB1B MB1C VA01 F-02 F-30 Regards, Karthik.k

  • Problem running RWBUILDER

    Hello All, Can you please help me run the 'rwbuilder' executable on Red Hat Linux ES 3.0. I have installed Oracle developer suite with no problems and when I try to run the Report Builder (rwbuilder), I have the following errors .. I checked my LD_LI

  • Clear password cache

    Does anyone have a method to clear the password cache programmatically? I want to prevent access to password protected block diagrams after I've done some block diagram changes but without restarting LabVIEW or navigating the Options menu Thanks Al

  • Numbering issue

    I am having an issue with numbers restarting in the middle of a list of numbered steps when I have a paragraph or figure in the middle of steps. Here's an example of what's happening. 1. My first step numbers correctly. 2. My second step numbers corr