Save file in various formats

Anyone, especially newbies, asking for help with photoshop scripting and photoshop automation - as opposed to those contributing to discussion about an aspect of photoshop scripting

Moderators: Patrick, Mike Hale, xbytor, Larry Ligon, Andrew, PS-Moderators

Save file in various formats

Postby rossi256 » Fri Mar 09, 2012 4:58 am

Hi everybody - i am doing a lot of photos that i need to save to the same sub-folders on different project-root folders.
the purpose is to have a full resolution PSD file on an external HDD, a high res JPG locally in one folder and a low res JPG in another local folder.
means:
save the PSD to
K:\root1\path1\filename.PSD
save high res jpg (quality 7) to
D:\root2\path1\filename.jpg
save low res jpg (1500pixels wide, quality 6) to
D:\root3\path1\filename.jpg

I would want to work on the file, press a hotkey and run that script --> it asks me for a folder and filename to save the PSD to and once i press save, also saves the JPGS as by the rules above.
I can hardcode the root folders, the path1 would be created sometimes when i create the PSD and should also be created if not exists in root2 and root3's.

Now i started by capturing the save-commands and trying to find some dialog to choose a folder... here what i have till now - but now i am already stuck with the script telling me that split is not a function -
Also i don't know how to check if the folder exists below root2 and root3 and create the directory if necessary...

Code: Select all
// Copyright 2007.  Adobe Systems, Incorporated.  All rights reserved.
// This script demonstrates how to use checkbox with ScriptUI.

// Settings
#target photoshop
app.displayDialogs = DialogModes.NO; // suppress all dialogs
app.bringToFront(); // bring top
$.localize = true;  // Enable ZString localiation

// Debugging
// debug level: 0-2 (0:disable, 1:break on error, 2:break at beginning)
// $.level = 0;
// debugger; // launch debugger on next line



// Pops open a dialog for the user to set the output folder
var psdfolder = ("K:\\root1");
var jpghrfolder = ("D:\\root2");
var jpglrfolder = ("D:\\root3");

   var outputFolder = Folder.selectDialog("Select a folder for the output files"); // here i would choose a folder like K:\sequences\image1\
   

// show the path to an output folder
   
   alert(outputFolder); //only for debugging
   
var splitpath1= outputFolder.split("sequences",1); //I thought i'd split that folder so i have only the path1


// var AD = activeDocument ;


// =======================================================
function savepsd() {
var idsave = charIDToTypeID( "save" );
    var desc416 = new ActionDescriptor();
    var idAs = charIDToTypeID( "As  " );
        var desc417 = new ActionDescriptor();
        var idmaximizeCompatibility = stringIDToTypeID( "maximizeCompatibility" );
        desc417.putBoolean( idmaximizeCompatibility, false );
    var idPhtthree = charIDToTypeID( "Pht3" );
    desc416.putObject( idAs, idPhtthree, desc417 );
    var idIn = charIDToTypeID( "In  " );
    desc416.putPath( idIn, new File( psdfolder+splitpath1 ) );
executeAction( idsave, desc416, DialogModes.NO );
}

// =======================================================
function savejpg_hr() {
var idsave = charIDToTypeID( "save" );
    var desc418 = new ActionDescriptor();
    var idAs = charIDToTypeID( "As  " );
        var desc419 = new ActionDescriptor();
        var idEQlt = charIDToTypeID( "EQlt" );
        desc419.putInteger( idEQlt, 6 );
        var idMttC = charIDToTypeID( "MttC" );
        var idMttC = charIDToTypeID( "MttC" );
        var idNone = charIDToTypeID( "None" );
        desc419.putEnumerated( idMttC, idMttC, idNone );
    var idJPEG = charIDToTypeID( "JPEG" );
    desc418.putObject( idAs, idJPEG, desc419 );
    var idIn = charIDToTypeID( "In  " );
    desc418.putPath( idIn, new File( jpghrfolder+splitpath1 ) );
    var idCpy = charIDToTypeID( "Cpy " );
    desc418.putBoolean( idCpy, true );
executeAction( idsave, desc418, DialogModes.NO );
}

// =======================================================
function downsize1500() {
var idImgS = charIDToTypeID( "ImgS" );
    var desc420 = new ActionDescriptor();
    var idWdth = charIDToTypeID( "Wdth" );
    var idPxl = charIDToTypeID( "#Pxl" );
    desc420.putUnitDouble( idWdth, idPxl, 1500.000000 );
    var idscaleStyles = stringIDToTypeID( "scaleStyles" );
    desc420.putBoolean( idscaleStyles, true );
    var idCnsP = charIDToTypeID( "CnsP" );
    desc420.putBoolean( idCnsP, true );
    var idIntr = charIDToTypeID( "Intr" );
    var idIntp = charIDToTypeID( "Intp" );
    var idBcbc = charIDToTypeID( "Bcbc" );
    desc420.putEnumerated( idIntr, idIntp, idBcbc );
executeAction( idImgS, desc420, DialogModes.NO );
}

// =======================================================
function savejpg_lr() {
var idsave = charIDToTypeID( "save" );
    var desc421 = new ActionDescriptor();
    var idAs = charIDToTypeID( "As  " );
        var desc422 = new ActionDescriptor();
        var idEQlt = charIDToTypeID( "EQlt" );
        desc422.putInteger( idEQlt, 6 );
        var idMttC = charIDToTypeID( "MttC" );
        var idMttC = charIDToTypeID( "MttC" );
        var idNone = charIDToTypeID( "None" );
        desc422.putEnumerated( idMttC, idMttC, idNone );
    var idJPEG = charIDToTypeID( "JPEG" );
    desc421.putObject( idAs, idJPEG, desc422 );
    var idIn = charIDToTypeID( "In  " );
    desc421.putPath( idIn, new File( jpglrfolder+splitpath1  ) );
    var idCpy = charIDToTypeID( "Cpy " );
    desc421.putBoolean( idCpy, true );
executeAction( idsave, desc421, DialogModes.NO );
}

// =======================================================
function closedontsave() {
var idCls = charIDToTypeID( "Cls " );
    var desc423 = new ActionDescriptor();
    var idSvng = charIDToTypeID( "Svng" );
    var idYsN = charIDToTypeID( "YsN " );
    var idN = charIDToTypeID( "N   " );
    desc423.putEnumerated( idSvng, idYsN, idN );
executeAction( idCls, desc423, DialogModes.NO );
}


would be glad for any help!!!
thanks!!
Michael
rossi256
 
Posts: 1
Joined: Thu Mar 08, 2012 5:52 am

Return to Help Me

Who is online

Users browsing this forum: Google [Bot] and 0 guests

cron