What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Scripting Script doesn't work


Mackbay

Member
Messages
8
Likes
1
Hi everyone,

I usually use photoshop to create textures for 3D projects. My steps to create it is creating the textures in differents layers. Then, I put together in a folder (inside the photoshop file) and when I created a large amount of textures inside the same file, I export each folder to jpeg. to get as many textures as folders I made.

To improve the efficiency of this process, I downloaded an script that export each folder to JPEG, besides it save each JPEG with the name of the file (with all characters) + the name of the folder.

But the problem started when I updated to Mavericks. Everything works well but the name of the file only have 10 characters at the most.

Anyone know what have happened with the script?

I don't have any idea to program, due to I attach the file in order to if someone could help me to solve this problem.

Please could somebody help me to fix the script?

Thanks a lot!
 

Attachments

  • Photoshop CS6 groups to jpeg.zip
    1.3 KB · Views: 1

Mackbay

Member
Messages
8
Likes
1
Looking for the source of the problem, I realized that the problem could not be the script. I say it due to I realized that when I'm at the "save" window, When I change format to JPEG, the program automatically change the name. I think that If I solve it, I could solve the whole problem. How could I correct it?

Thanks a lot!
 

Paul MR

The Script Master
Messages
382
Likes
206
I have had a look at the code and made some comments and alterations, I haven't tested it though...

Code:
#target photoshop
function main(){
if(!documents.length) return;
var doc = activeDocument;
var dName = decodeURI(activeDocument.name).replace(/\.[^\.]+$/, '');
var oldPath = (activeDocument.path);
var rndrDir = new Folder(oldPath+"/"+"JPEG");
      if(!rndrDir.exists) rndrDir.create();
//the /JPEG/ should be in quotes
//Why are you re declaring the output folder?
//rndrDir has been declared as the output folder and created if it did not exist
//var newPath = (activeDocument.path + /JPEG/);
for(var a=0;a<doc.layerSets.length;a++){
activeDocument.activeLayer = activeDocument.layers.getByName(doc.layerSets[a].name);
//get the layers name before the layer is duplicated to its own document.
var lName = doc.layerSets[a].name;
//the following line duplicates the layer to its own document
dupLayers();
//the following line should not be required as only one layer copied
activeDocument.mergeVisibleLayers();
//newPath was incorrect, doc.layerSets[a].name does not exist as this layer is now by itself in its own document.
//var saveFile= File(newPath +"/"+dName+" - "+doc.layerSets[a].name +".jpg");
var saveFile= File(rndrDir +"/"+dName+" - "+ lName +".jpg");
SaveJPEG(saveFile, 12);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
    }
}
main();
function dupLayers() {
    var desc143 = new ActionDescriptor();
        var ref73 = new ActionReference();
        ref73.putClass( charIDToTypeID('Dcmn') );
    desc143.putReference( charIDToTypeID('null'), ref73 );
    desc143.putString( charIDToTypeID('Nm  '), activeDocument.activeLayer.name );
        var ref74 = new ActionReference();
        ref74.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
    desc143.putReference( charIDToTypeID('Usng'), ref74 );
    executeAction( charIDToTypeID('Mk  '), desc143, 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);
}
 

Mackbay

Member
Messages
8
Likes
1
Thank you for your answer!

I check the script on photoshop but the result is the same. I think that sth has changed in photoshop because in Mountain Lion when I was in save window and I chose to jpeg format, the name didn't changed, but now when I choose jpeg format, the name changes.

Thank you to check the script!
 

Mackbay

Member
Messages
8
Likes
1
Using Mavericks I realized that it happens with other programs, but I don't know why but now photoshop script works well. I don't know why because I haven't change anything but it works! thank you for all your answers!
 

Top