Article View: adobe.photoshop.scripting
Article #208Re: Could anyone please help me...
From: christoph_pfaffenbichler
Date: Thu, 19 Mar 2009 08:14
Date: Thu, 19 Mar 2009 08:14
156 lines
4062 bytes
4062 bytes
First: The headline to Your query is not very informative, a more specific definition of topic would seem a better choice.
Secondly: I haven�t tested it extensively and I�m not very experienced with Scripting, but You could give this a try:
// this script tries to copy the clipping paths of files in one folder into files of the same name in another folder;
// use it at your own risk;
#target photoshop
var withPath = Folder.selectDialog("select the folder containing the images with paths");
var withoutPath = Folder.selectDialog("select the folder containing the images without paths");
if (!withPath || !withoutPath) {}
else {
var theOnesWith = withPath.getFiles();
var theOnesWithout = withoutPath.getFiles();
var notFound = new Array;
for (var m = 0; m < theOnesWith.length; m++) {
var checksOut = false;
theOne = theOnesWith[m];
for (var n = 0; n < theOnesWithout.length; n++) {
theOtherOne = theOnesWithout[n];
// compare file-names;
if (theOne.name.slice(theOne.name.lastIndexOf("/")+1,-4) == theOtherOne.name.slice(theOtherOne.name.lastIndexOf("/")+1,-4)) {
checksOut = true;
photoshop.open(theOtherOne);
var theUnpathed = app.activeDocument;
photoshop.open(theOne);
var thePathed = app.activeDocument;
for (var o = 0; o < thePathed.pathItems.length; o++) {
app.activeDocument = thePathed;
var aPath = thePathed.pathItems[o];
// look for clipping path;
if (aPath.kind == PathKind.CLIPPINGPATH) {
aPath.select();
copyPath (thePathed, theUnpathed, aPath.name);
app.activeDocument = theUnpathed;
theUnpathed.pathItems[theUnpathed.pathItems.length-1].makeClippingPath(1)
}
else {}
}
}
else {};
try {
thePathed.close(SaveOptions.PROMPTTOSAVECHANGES);
theUnpathed.close(SaveOptions.PROMPTTOSAVECHANGES);
// for automatic saving clear previous line and remove the two slashes in the following line;
// theUnpathed.close(SaveOptions.SAVECHANGES);
}
catch (e) {};
}
if (checksOut == false) {
notFound = notFound.concat(theOne.name.slice(theOne.name.lastIndexOf("/")+1,-4))
}
else {}
};
if (notFound.length > 0) {
alert ("no corresponding file/s in the second folder found for \n" + notFound.join("\n"))
}
};
////// by nic bereznikov //////
function copyPath( From, To, PathName) {
// Select source document
activeDocument = From;
// define function
cTID = function(s) { return app.charIDToTypeID(s); };
// Select path
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putName( cTID( "Path" ), PathName);
desc.putReference( cTID( "null" ), ref );
executeAction( cTID( "slct" ), desc, DialogModes.NO );
// Copy path
executeAction( cTID( "copy" ), undefined, DialogModes.NO );
// Select destination document
activeDocument = To;
// Paste path
executeAction( cTID( "past" ), undefined, DialogModes.NO );
// Deselect path
//desc.putReference( cTID( "null" ), ref );
//executeAction( cTID( "Dslc" ), desc, DialogModes.NO );
}
Technical Details
Message-ID:
<59b85097.0@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newshub.sdsu.edu!webcrossingReferences:
<59b85097.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f5839,4bc63ffe0c2df591 X-Google-Attributes: gidf5839,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII From: christoph_pfaffenbichler@adobeforums.com Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.photoshop.scripting Subject: Re: Could anyone please help me... Message-ID: <59b85097.0@webcrossing.la2eafNXanI> Date: Thu, 19 Mar 2009 01:14:06 -0700 References: <59b85097.-1@webcrossing.la2eafNXanI> Lines: 111 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit