I've been using this script and action for years. Got a new Mac and now I get the attached error.
Here's the process:
- Action that first deletes alpha channels,
- Then un-does any clipping paths
- Call this script (which has a specific file hierarchy it needs).
- Then I get the attached error
- Photoshop CC 2018 19.0
- OS X 10.12.6
Any thoughts? Thanks!
![Capto_Capture 2017-11-17_09-52-47_AM.png]()
// Pfade übernehmen v2.1
// Copyright Thamer Florian
// 30.11.2010
var docRef = app.activeDocument;
var docJPG= app.activeDocument;
// Check for a "TIF","PSD","JPG" Subdirectory, which contains the Images where the paths should be applied to.
var checksum = "0";
for( var i = "1"; i <= "3"; i++){
if( i == "1" ) {
var newpath = docRef.path + "/TIF/";
newpath = new File(newpath);
if(newpath.exists) {
checksum++;
var dateityp = "TIF";
}
}
if( i == "2" ) {
var newpath = docRef.path + "/PSD/";
newpath = new File(newpath);
if(newpath.exists) {
checksum++;
var dateityp = "PSD";
}
}
if( i == "3" ) {
var newpath = docRef.path + "/JPG/";
newpath = new File(newpath);
if(newpath.exists) {
checksum++;
var dateityp = "JPG";
}
}
}
if( checksum > "1") alert("Error! please create a single tif, psd or jpg subfolder"); // Error if there is more than one possible subdirectory
if( checksum < "1") alert("Error! No tif, psd or jpg subfolder available"); // Error if there is no possible subdirectory
if( checksum == "1") { // The Script will only run if there is exacly ONE compatible subdirectory
// open the TIF/PSD/JPG file with the same name as the JPG
var jpg = docRef.name;
var fname = docRef.name.split(".");
var fname1 = "";
for (var k = 0; k <= fname.length - 2; k++) {
fname1 = fname1 + fname[k] + ".";
}
var fnamenew = fname1 + dateityp;
var newpath = docRef.path + "/" + dateityp + "/" + fnamenew;
var docRef = app.activeDocument;
var TIF = newpath;
// Opening the TIF/PSD/JPG file
var TIFShortcut = new File(TIF);
if( !TIFShortcut.exists ) {
alert("Oops! File " + TIFShortcut + " not found!" + jpg + " remains open"); // if the file does not exist stop scripts
}
else {
var docTIF = open(TIFShortcut);
// Check Resolution/Canvas size
app.activeDocument = docJPG;
if( docTIF.resolution != docJPG.resolution ) var sizeerr = "";
if( (docTIF.width != docJPG.width) || (docTIF.length != docJPG.length) ) var sizeerr = "";
if (sizeerr != null) {
alert("Document Size / Resolution different! \ NThe file" + jpg + " has a wrong document size / resolution. \ It will remain open");
docTIF.close();
}
else {
// Check color mode, color profile and bits per channel, and correct them
if( docTIF.mode != docJPG.mode ) docJPG.convertProfile(docTIF.colorProfileName, Intent.RELATIVECOLORIMETRIC, true, true);
if( docTIF.colorProfileName != docJPG.colorProfileName ) docJPG.colorProfileName = docTIF.colorProfileName;
if( docTIF.bitsPerChannel != docJPG.bitsPerChannel) docJPG.bitsPerChannel = docTIF.bitsPerChannel;
// So this is where i copy all the layers from the e.g. TIF to the JPG with paths
// I use the Select All Layers Command (cmd+alt+A - as far as i know not accessible through a menu)
// Problem is: It select all Layers EXCEPT the background layer
// So if there is a BG Layer i convert it to a normal layer first and rebackgroundize it afterwards.
app.activeDocument = docTIF;
var ebenen = docTIF.artLayers.length-"1";
if (docTIF.artLayers[ebenen].isBackgroundLayer == true) {
docTIF.artLayers[ebenen].isBackgroundLayer = false;
var hgset = "1";
}
// Select all layers
// =======================================================
var idselectAllLayers = stringIDToTypeID( "selectAllLayers" );
var desc14 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref8 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref8.putEnumerated( idLyr, idOrdn, idTrgt );
desc14.putReference( idnull, ref8 );
executeAction( idselectAllLayers, desc14, DialogModes.NO );
// DRAG all layers to the other document, this increases speed, cause nothing goes into clipboard
// and I don't copy layer by layer.
// =======================================================
var idDplc = charIDToTypeID( "Dplc" );
var desc50 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref40 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref40.putEnumerated( idLyr, idOrdn, idTrgt );
desc50.putReference( idnull, ref40 );
var idT = charIDToTypeID( "T " );
var ref41 = new ActionReference();
var idDcmn = charIDToTypeID( "Dcmn" );
ref41.putName( idDcmn, jpg ); // jpg = target document
desc50.putReference( idT, ref41 );
var idVrsn = charIDToTypeID( "Vrsn" );
desc50.putInteger( idVrsn, 5 );
executeAction( idDplc, desc50, DialogModes.NO );
// close the original TIF/PSD/JPG file
docTIF.close(SaveOptions.DONOTSAVECHANGES);
// delete the layer from the JPG file that has been in Asia
var ebenen = docRef.artLayers.length-1;
docRef.artLayers[ebenen].remove();
// set the bottom layer as background if it was before
if (hgset) {
var ebenen = docRef.artLayers.length-1;
docJPG.artLayers[ebenen].isBackgroundLayer = true;
}
// and finally overwrite TIF/PSD/JPG in the TIF/PSD/JPG subdirectory
switch( dateityp ) {
case("TIF"): docRef.saveAs(new File(newpath),TiffSaveOptions); break;
case("PSD"): docRef.saveAs(new File(newpath),PhotoshopSaveOptions); break;
case("JPG"): docRef.saveAs(new File(newpath),JPEGSaveOptions); break;
}
docRef.close();
}
}
}