🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.photoshop.scripting
3 messages
3 total messages Started by wanasako Wed, 18 Mar 2009 11:01
Could anyone please help me...
#204
Author: wanasako
Date: Wed, 18 Mar 2009 11:01
5 lines
848 bytes
would like to have a batch processing script or action for copying some clipping paths from pictures(have paths inside) to pictures(don't have). they are in the same name but difference location.

Folder A (Pic's name 1,2,3,4,...) ---- copy paths to-----> Folder B (Pic's name 1,2,3,4,...)

Thanks
Re: Could anyone please help me...
#208
Author: christoph_pfaffenbichler
Date: Thu, 19 Mar 2009 08:14
156 lines
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 ); 

}
Re: Could anyone please help me...
#209
Author: wanasako
Date: Thu, 19 Mar 2009 09:33
10 lines
941 bytes
// This is Photoshop, so just call our DOM routine with the files		
		var fileArray = photoshop10.ExtractFileArray (files);

		for (index = 0; index < fileArray.length; ++index) 			{ 			var file = fileArray[index];

			app.open (file); <<<<<< Cannot open the file because the open options are incorrect.

			}

Regard ^.^ and thank you very muchhhhhhhhh
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads