Need a batch script automate "Crop & straighten.

So, I have a few hundred image files which consist of 3 or 4 scanned photos, also called 'gang' scanned. The ability "Crop & straighten" Photoshop (located under the folder-> controller) is great... But I want to be abe to run a script that will ask me for a file to be processed and then run culture & straighten it on all the pictures, so that their savings to another folder called "Édition" or something.  I found a script in the forums for this exact purpose, but it doesn't seem to work in CS5.  I ran it several times, it creates the folder "Edited", but nothing is inside. The script that I found is shown below. Any ideas? I would really appreciate the help!

#target Photoshop
app.bringToFront;
var inFolder = Folder.selectDialog("Please select folder to process");
if(inFolder != null){
var fileList = inFolder.getFiles(/\.(jpg|tif|psd|)$/i);
var outfolder = new Folder(decodeURI(inFolder) + "/Edited");
if (outfolder.exists == false) outfolder.create();
for(var a = 0 ;a < fileList.length; a++){
if(fileList[a] instanceof File){
var doc= open(fileList[a]);
doc.flatten();
var docname = fileList[a].name.slice(0,-4);
CropStraighten();
doc.close(SaveOptions.DONOTSAVECHANGES);
var count = 1;
while(app.documents.length){
var saveFile = new File(decodeURI(outfolder) + "/" + docname +"#"+ zeroPad(count,3) + ".jpg");
SaveJPEG(saveFile, 12);
activeDocument.close(SaveOptions.DONOTSAVECHANGES) ;
count++;
  }
}
}
};
function CropStraighten() {
executeAction( stringIDToTypeID('CropPhotosAuto0001'), undefined, DialogModes.NO );
};
function SaveJPEG(saveFile, jpegQuality){
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = jpegQuality;
activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);
}
function zeroPad(n, s) {
n = n.toString();
while (n.length < s) n = '0' + n;
return n;
};

The script finds only files jpg, tif or psd, if your files are differenent format this format would need to add to the script.

It could also be a problem with the editor allows you to save the script, some programs will add control characters and stop the operation of the script.

It is best to use the ExtendScript Toolkit, as is the program installed with Photoshop for editing/testing scripts.

Tags: Photoshop

Similar Questions

  • batch automate crop &amp; straighten, save as tiff

    Hello

    Can someone please help with change the script Crop & straighten following. I need to change the Save TIFF and jpeg settings not.

    The script works perfectly, I just need to save all files as well as tiff

    #target Photoshop

    app.bringToFront;

    var InFolder = Folder.selectDialog ("Please select folder to process");

    If (InFolder! = null) {}

    List of files of the var = inFolder.getFiles (/ \.) (jpg) | TIF | PSD |) $/i);

    var = new Folder outfolder (decodeURI (inFolder) + ' / edition ");

    If (outfolder.exists == false) outfolder.create ();

    for (var a = 0; a < fileList.length; a ++) {}

    If {([a] instanceof fichier fileList)}

    var doc = open (fileList [a]);

    doc. Flatten();

    var Nomdoc is fileList [a].name.slice (0, -4);.

    CropStraighten();

    doc. Close (SaveOptions.DONOTSAVECHANGES);

    var count = 1;

    {while (App.Documents.Length)}

    var saveFile = new queue (decodeURI (outfolder) + "/" + Nomdoc + "#" + zeroPad(count,3) + ".jpg");

    SaveJPEG (saveFile, 12);

    activeDocument.close (SaveOptions.DONOTSAVECHANGES);

    Count ++;

    }

    }

    }

    };

    function CropStraighten() {}

    executeAction (stringIDToTypeID ('CropPhotosAuto0001'), undefined, DialogModes.NO);

    };

    function SaveJPEG (saveFile, jpegQuality) {}

    jpgSaveOptions = new JPEGSaveOptions();

    jpgSaveOptions.embedColorProfile = true;

    jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;

    jpgSaveOptions.matte = MatteType.NONE;

    jpgSaveOptions.quality = jpegQuality;

    activeDocument.saveAs (saveFile, jpgSaveOptions, true, Extension.LOWERCASE);

    }

    function zeroPad (n, s) {}

    n = n.toString ();

    While (n.length < s) n = '0' + n;

    return n;

    };

    This is a tiff.

    #target Photoshop
    app.bringToFront;
    var inFolder = Folder.selectDialog("Please select folder to process");
    var fileList = inFolder.getFiles(/\.(jpg|tif||psd|)$/i);
    var outfolder = new Folder(decodeURI(inFolder) + "/Edited");
    if (outfolder.exists == false) outfolder.create();
    for(var a = 0 ;a < fileList.length; a++){
      if(fileList[a] instanceof File){
      var doc= open(fileList[a]);
      doc.flatten();
      var docname = fileList[a].name.slice(0,-4);
      executeAction( stringIDToTypeID('CropPhotosAuto0001'), undefined, DialogModes.NO );
      doc.close(SaveOptions.DONOTSAVECHANGES);
    var count = 1;
    while(app.documents.length){
      var saveFile = new File(decodeURI(outfolder) + "/" + docname +"#"+ zeroPad(count,3) + ".tif");
      SaveTIFF(saveFile);
      activeDocument.close(SaveOptions.DONOTSAVECHANGES);
      count++;
      }
      }
    }
    function SaveTIFF(saveFile){
    tiffSaveOptions = new TiffSaveOptions();
    tiffSaveOptions.embedColorProfile = true;
    tiffSaveOptions.alphaChannels = true;
    tiffSaveOptions.imageCompression = TIFFEncoding.TIFFLZW;
    activeDocument.saveAs(saveFile, tiffSaveOptions, false, Extension.LOWERCASE);
    };
    function zeroPad(n, s) {
       n = n.toString();
       while (n.length < s)  n = '0' + n;
       return n;
    };
    
  • Run the script automatically when Windows goes into hibernation or wakes up?

    Hello

    I use the group policy feature in Windows XP to run scripts automatically when you open a session or logoff.

    But it is also possible to make a script run automatically, whenever a Windows-xp machine is about to Hibernate? And also when it wakes up from hibernation?

    The clues how to proceed?

    A funny hibernation is that if you put into hibernation and power then upwards and don't 'do' nothing - like press a key or move the mouse (just to sit and watch), in 300 seconds (5 minutes), XP will go back into Hibernation automatically.  Try it!

    XP does because after it comes out of Hibernation, if XP detects that there is nothing to 'do', he thinks he might be from Hibernation by accident and goes back to "sleep" and said "why you wake me up?

    That's why when people hibernate during the night and their machine turn on the morning he wakes up, they make their coffee or breakfast and return later to see that they have the power of their machine again.  If they think something is wrong, but things are working as expected.

    One way to fix this, is to use a third-party tool that uses the command line to simulate a mouse movement.   It is enough to prevent the rehibernating while you are on XP.

    To simulate a movement of the mouse as soon as your system is equipped with Hibernation, you will need to download the nircmd.exe file.

    There are many other utilities of vouchers on NirSoft main page:
    http://www.NirSoft.NET/

    To simulate the movement of the mouse, download the file nircmd.exe here

    http://www.NirSoft.NET/utils/nircmd2.html

    Put the nircmd.exe file in a folder which is somewhere in your path (c:\windows\system32, etc.) or consult the path in your command file. I put the nircmd.exe file in my c:\tools folder where I keep other things.

    If you do not have Hibernate enabled in your Power Options, tab hibernation, it will put your system on Stand-By instead of Hibernation.

    Create a batch file (I called mine hibernate.bat and put the nircmd.exe in my c:\tools folder) and put this line in your hibernate.bat file:

    off @echo
    Powrprof.dll, SetSuspendState c:\WINDOWS\system32\rundll32.exe Hibernate
    c:\tools\nircmd.exe 10 10 movecursor
    movecursor-10 c:\tools\nircmd.exe - 10

    Save the new file hibernate.bat on your desktop or somewhere, you can retain and double-click it to run the batch file.  When you are sure that it works very well, and then drag the new desktop icon to your quick launch area (to the right of the button start), change the icon, rename, etc, so it looks a bit better and then you can click on new quick launch when icon to call the file hibernate.bat.  Now just remember to use the hibernate.bat file (which could be on your desktop with a nice icon) instead of the menu to turn off the computer.

    The first command will put the system into hibernation, and then when XP comes from hibernation (even days later), run the following commands in the batch file.  These last two commands will simulate a slight mouse movement and who will deceive XP into thinking there is a reason to get out of hibernation and it will not go back to sleep.  Then when you come back from your coffee, your system is always waiting for you.

    If your case, your hibernate.bat might look something like:

    off @echo
    order 1 run before hibernation
    2 run before hibernation command
    order 3 to run before hibernation

    Powrprof.dll, SetSuspendState c:\WINDOWS\system32\rundll32.exe Hibernate

    order 4 to run when coming out of hibernation
    command 5 to run when coming out of hibernation
    order 6 to run when coming out of hibernation

  • Automatic cropping?

    Hey guys,.

    I'm scanning a bunch old pictures mounted on some sort of sheet of cardboard. I wonder if there is a way to batch these photos with a sort of automatic cropping that removes all the pixels around the photo itself, i.e. the sheet of cardboard?  Instead of manually opening images and by cutting the photo itself.

    Here are some examples:

    [img] http://i.imgur.com/6mq2jqN.jpg [line]

    [img] http://i.imgur.com/wVJjEdx.jpg [line]

    Appreciate any help! / Rick

    Try the following:

    File > automate > crop and straighten Photos

  • Change the LV version currently active in the batch script

    Hello

    I use two different applications on my computer, and one of them should run in LV 2011, this in LV 2012. The two versions are installed and it works fine until I start the correct version of LV manually before you start the application (start and end of the required version of LV in C:\Program Files (x 86) \National Instruments\... before starting my request).

    I want to do this automatically in a command script, so basically I want to do the following:

    * Check which version of LV is currently active (last LV start version)

    * If the currently active version of LV is NOT required: change to the required version of LV (by starting LV and close or preferably do differently if someone could tell me how)

    * If the currently active version of LV is required: do nothing

    There are two problems I couldn't solve so far:

    * How to get the LV version currently active (I checked the windows registry, but I see that my installed versions of LV, and not one that is currently active)

    * How can I close LV with a batch script (or how to change the version of the currently active LV without opening and closing)

    Thanks in advance,

    Tobias

    PS: I did the same for the different versions of TestStand, by reading the TestStand system and if requuired environment variable change the version of TestStand via the command-line of the TS Version selector. It works fine, but there is no system environment variable that indicates the currently active version of LV.

    OK, this is a very informal Tip:

    In the registry (regedit), you will find the key 'HKEY_CLASSES_ROOT\LabVIEW.Application\CLSID '. This default key should contain some weird ID information.

    If you search for this key, you will find an entry for the key in the "HKEY_CLASSES_ROOT CLSID" section.

    If you have several versions of installed LV, there must be a key in the entry which will give you the path to the active version of NV. don't forget: this is the version that you have opened up to the last successfully!

    Please note that keys can change from system to System. Also different versions of LV can use different keys like "routing information" the way of the real LabVIEW.exe.

    hope this helps,

    Norbert

  • Need help with script java folder level for silent registration with unique file name

    That's what I'm trying to do

    1. when a person completes the request on one of our computers in the office, there will be a button send at the bottom of the application.

    2 submit the application on is automatically stored on the local server with the file name determined by the fields name and surname on the application.

    example - John Doe Application.pdf

    Saved in the folder C:\Users\Station1\Desktop\FinishedApplication.jpgApplications

    3. This is the example of code I found, but I don't know how to enter which fields determine save name and where to save it to.

    http://thelivecycle.blogspot.de/2015/06/save-with-new-name-in-specified.html

    http://thelivecycle.blogspot.de/2015/06/save-with-new-name-in-specified.html http://thelivecycle.blogspot.com/2009/11/save-form-to-specific-directories-and.html

    Thank you!

    Lol this is the part that you need as a script to the folder level:

    var lcbSaveAs = app.trustedFunction (function (vDoc, vPath) {}

    app.beginPriv ();

    vDoc.saveAs ({cPath: vPath});

    app.endPriv ();

    });

    This is the code you use in your file:

    lcbSaveAs (, "/ C/users/specialisee1/Desktop/result /" + this.getField("FirstName").valueAsString + "" + this.getField("LastName").valueAsString + "Application.pdf");

    lcbSaveAs is the name of the function of trust.

    vDoc.saveAs is the Document object, call the saveAs method.

    I don't know what oDoc.SaveAs is, or where you got it.

  • How to hide the user id and password in the batch scripts

    Hello

    Can help me hide the user id and the password in the batch scripts to automate the process of running script to export and action.

    Context: In my client project does not display user id and password that's why they are looking for guaranteed way to hide them.

    Thanks for your response in advance.

    Kind regards

    Sandra.

    Sandra,

    As stated by Craig Administrator's Guide is a good option.

    Let me give you a few steps I did in one of my projects.

    Open the command prompt and navigate to the location "C:\Oracle\Middleware\EPMSystem11R1\products\DataRelationshipManagement\client\batch-client"... here you can see many see as well other utilities.

    DRM-batch-customer - credentials.exe is the one that is used to encrypt the user name and password.

    Open this in the command prompt and choose the application that you want to encrypt the password.

    then remove the username and password from command script can run it... It does what you want

  • Using single quotes with MaxL in batch scripts

    I have the following MaxL, I need to pass to essmsh via a batch script:

    run the calculation ' FIX("Member 1") CLEARDATA "member 2"; ENDFIX' on App.Db;

    The problem is that the single quotes cause problems when it is passed as a variable in the batch script. However, if I change single quotes to double quotes the batch script is happy but the MaxL is not valid.

    Please can anyone suggest how I can get this to work?

    You also try that works

    ( @echo login %USER% identified by %PASS% on %SERVER%; & @echo execute calculation "'FIX(\"Member 1\") CLEARDATA \"Member 2\"; ENDFIX'" on App.Db; & @echo logout; & @echo exit; ) | essmsh
    

    See you soon

    John
    http://John-Goodwin.blogspot.com/

  • Script to crop only odd or even pages in Acrobat

    Someone at - it script to crop the even or odd pages only through batch processing. I use the same settings of harvesting almost every day and would like to be able to define a batch process for this. I copr parameters for odd and even pages, so I can't use the basic crop tool already contained in the batch. Thanks for any help.

    I copr parameters for odd and even pages, so I can't use the basic crop tool already contained in the batch.

    Why not?

  • Is there a a way to "Consolidate all" using the FDM parallel batch Script?

    Hello

    When you run the BatchStdParallel script in FDM, the lngProcessLevel will take place in the consolidation, but it's only "consolidate" in HFM. I would like to know if there is a way instead "consolidate all With Data. Does anyone know if there is a way to do this?

    Here is the part of the script. Any help would be greatly appreciated,

    Dim BATCHENG
    Set BATCHENG = CreateObject ("upsWBatchLoaderDM.clsBatchLoader")
    BATCHENG.mInitialize API, SCRIPTENG

    ' Initialize variables Variables
    lngProcessLevel = 10 ' top consolidate
    strDelimiter = "_" ' delimiter in file name
    blnAutoMapCorrect = True ' automatic Correction of the card is on
    lngParallelProcessCount = 2 ' the number of parallel processes (must equal the number of processors)
    strLoadBalanceServerName = "MCK120" "server load for a parallel balance

    Check your settings for integration. The strengthening method is not specified by the batch script.

  • Audition 2.0 current Batch Script interrupted, do not save completed

    I'm trying prun a script on a few hundred mp3 files to increase the volume.  It's here

    Collection: normal120-economy
    Title: Untitled
    Description:
    Mode: 4
    Cancel: 1

    Selected: 0 to 6197758 scale 6197758 SR 44100
    FREQ: Off
    cmd: channels

    Selected: 0 to 6840575 scale 6197758 SR 44100
    FREQ: Off
    Comment: Amplitude\Normalize (process)
    cmd: {7EC45406-CFB6-4C54-99B9-84CE080C1914}
    1: 1
    2: 0
    3: 0
    4: 1.2
    5: 0

    FREQ: Off
    At the end:

    However, after a single file, it stops with error "Interrupted Batch Script, current save not completed" do I need to add a pause before the next file? (how) or any idea what causes the error?  Please, I have 3 000 files to do to and individually he kills me!

    To start the line

    Selected: 0 to 6840575 scale 6197758 SR 44100

    is not a very good idea, because you try to select beyond the end of the file on which you operate. If you select 6197758 in the scale of 0 to 6197785 SR 44100, then you will select the entire file. But then again, if you have selected 0 to 1 scale 1 SR44100 you reach exactly the same thing.

    If you are using this as a part of a batch file and backups do not work properly, you'll probably need to check all the parameters of format in the treatment by lots - but try to fix the script so that it seem weird first.

  • How to delete a DATA FILE and rename the other DATA of FILE Batch scripts

    DELETE or DROP d:\NDM\Data\StampFiles\STAMPLOADBKUP.csv

    RANAME d:\NDM\Data\StampFiles\STAMPLOAD_cwoo.csv data file for d:\NDM\Data\StampFiles\STAMPLOADBKUP. CSV

    what works for use in support of scripting batch above and need exact syntax please. I am poor in the batch script.

    Concerning
    Soma

    ================
    D:

    CD d:\NDM\Data\StampFiles

    del STAMPLOADBKUP.csv

    Ren STAMPLOAD_cwoo.csv STAMPLOADBKUP. CSV

    ================

    That should do it for you!

  • How can I stop iMovie automatically crop my picture?

    I make an invitation left in iMovie, a single pdf file, set to music.  iMovie has automatically "cropped" my pdf, slowly zooming in on the center of the image, which means that I lose the information around the edges.  How do I stop iMovie automatically crop and zoom - I want just the full-size PDF to show?

    Looks like you have the ken burns effect turned on. Select your pdf file and click the crop button in the toolbar. Then select adjustment and you should be fine.

  • Hi I have just signed up for the Apple's music and I forgot to cancel my game from itunes (it is no longer needed) who crossed just automatically - how to cancel the game and can get a refund?

    Hi I have just signed up for the Apple's music and I forgot to cancel my game from itunes (it is no longer needed) who crossed just automatically - how to cancel the game and can get a refund?

    To stop renewing, login to your account (for example by tapping your id settings > iTunes & App Store on your iPad, or by clicking on your name / icon to the top right of the iTunes on iTunes on your computer screen), and go to the iTunes in the cloud Section - see to halfway down this page: subscribe to iTunes game - Apple Support

    In terms of refund, try to contact iTunes Support and see if this will change (purchases are considered final), either via http://reportaproblem.apple.com or http://www.apple.com/support/itunes/contact/

  • delete the printer driver by political group or batch script

    I am migrating our server F & P from 2003 to 2008.  I created all of the printers in server 2008 and tested, and they print correctly.  Test the issue I am running is this: I can add the printer Server 2008 for fine local workstation, but users are unable to print the new queue.  If I go ahead and deleted the printer and remove the driver completely and then add the printer on 2008 server works very well.  So, I'm looking for a way to remove printers and drivers of each workstation via Group Policy or batch scripts to make my life easier.  Thank you.

    Hello

    Given that the problem is related to the windows server, I suggest you post this question in the Windows Server Forums.
    http://social.technet.Microsoft.com/forums/en-us/winserverGP/threads

Maybe you are looking for