• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Script to copy all layers names into keywords metadata...sorting files which have layers

Participant ,
May 22, 2015 May 22, 2015

Copy link to clipboard

Copied

Hello

I need script that can copy all layers names to some metadata field in the same picture, like keywords or similar...In this way I can sort files in bridge which have layers to some subfolder   thanks

TOPICS
Actions and scripting

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
May 23, 2015 May 23, 2015

Copy link to clipboard

Copied

Code for collecting the layernames is available, this version also collect the layerIDs, though.

// 2015, use it at your own risk;

#target "photoshop-70.032"

if (app.documents.length > 0) {

app.activeDocument.suspendHistory("replace", "main ()");

};

////////////////////////////////////

function main () {

// the file;

var myDocument = app.activeDocument;

// get number of layers;

var ref = new ActionReference();

ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

var applicationDesc = executeActionGet(ref);

var theNumber = applicationDesc.getInteger(stringIDToTypeID("numberOfLayers"));

// process the layers;

var theLayers = new Array;

for (var m = 0; m <= theNumber; m++) {

try {

var ref = new ActionReference();

ref.putIndex( charIDToTypeID( "Lyr " ), m);

var layerDesc = executeActionGet(ref);

var layerSet = typeIDToStringID(layerDesc.getEnumerationValue(stringIDToTypeID("layerSection")));

var isBackground = layerDesc.getBoolean(stringIDToTypeID("background"));

// if not layer group collect values;

if (layerSet != "layerSectionEnd"/* && layerSet != "layerSectionStart" && isBackground != true*/) {

var theName = layerDesc.getString(stringIDToTypeID('name'));

var theID = layerDesc.getInteger(stringIDToTypeID('layerID'));

theLayers.push([theName, theID])

};

}

catch (e) {};

};

alert (theLayers.join("\n"));

};

But I wonder if Bridge-Scripting may not offer an easier solution for identifying layers files.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 23, 2015 May 23, 2015

Copy link to clipboard

Copied

Tnx for script but dont know how to put script output into keywords?

I ask in bridge scripting but no success. Bridge script will be great.

tif2jpeg conversion. How to find tif or photoshop eps files which have layers or transparencies???

Script to copy all layers names into keywords metadata...sorting files which have layers

Really strange that no one have this needs. I surf all over internet for days and nothing.

Spotlight in mac have some option but dont know how to use it and if it only for psd, i need for tiff:

Tips & Techniques: Spotlight sees PSD layer names, Adobe Bridge doesn't

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 23, 2015 May 23, 2015

Copy link to clipboard

Copied

#target "photoshop-70.032"

var doc = activeDocument;

doc.info.keywords = ["aaa", "bbb", "ccc"];// insert your actual content in the array

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 23, 2015 May 23, 2015

Copy link to clipboard

Copied

thanks for this but i dont know how to do this. My coworkers need to convert tif to jpegs but not files which have layers or transparency. So i need way to separate flattened tiff from one which have layers or transparency.

In this way I can make droplet.

Maybe is fast way to copy all layers name to clipboard and paste it into description/keywords field?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 23, 2015 May 23, 2015

Copy link to clipboard

Copied

Quite frankly it is peculiar for you to mention what the actual task is only now.

And your approach seems unnecessarily complicated.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 23, 2015 May 23, 2015

Copy link to clipboard

Copied

I assume a simple check for the number of Layers and if only one Layer exists whether it is the Background Layer may suffice.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 23, 2015 May 23, 2015

Copy link to clipboard

Copied

Yes. But because i cant write script i need finished javascript for pc, shop cs6. Simply, tif to jpeg but no one which have layers. In this way i will make droplet.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 23, 2015 May 23, 2015

Copy link to clipboard

Copied

And to skeep images which have transparency as weel.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 23, 2015 May 23, 2015

Copy link to clipboard

Copied

This determines if the active document has more than the background layer.

// 2015, use it at your own risk;

#target photoshop

if (app.documents.length > 0) {

var myDoc = app.activeDocument;

if (myDoc.layers.length == 1 && myDoc.layers[0].isBackgroundLayer == true) {

alert ("image has only background layer")

} else {

alert ("image has more than just a background layer")

}

};

Instead of the alerts you can insert whatever Photoshop operations you want.

Examples for saving tif and jpg are available on the Forum.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 23, 2015 May 23, 2015

Copy link to clipboard

Copied

I will save action. First step is to call this script and if here is layer close image?, open next and if here is no layer image stay open and save as jpeg.

Is this ok?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 24, 2015 May 24, 2015

Copy link to clipboard

Copied

// 2015, use it at your own risk; 

#target photoshop 

if (app.documents.length > 0) { 

var myDoc = app.activeDocument; 

if (myDoc.layers.length == 1 && myDoc.layers[0].isBackgroundLayer == true) { 

} else { 

activeDocument.close() 

}; 

Script close image if here is layers, good...but how to make it if here is NO layer to automatically save as jpeg with some setting to same folder as original? want to make droplet.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 24, 2015 May 24, 2015

Copy link to clipboard

Copied

There are numerous examples on this site, here are but a few.

Google

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 24, 2015 May 24, 2015

Copy link to clipboard

Copied

some progress

this work, bypass images with layers and save jpg from files without layers to source folder.

but how to kill alert window (the command close is currently unavailable), when run script from action panel? This is because script close image before last step "close" in action panel.

// 2015, use it at your own risk; 

#target photoshop 

if (app.documents.length > 0) { 

var myDoc = app.activeDocument; 

if (myDoc.layers.length == 1 && myDoc.layers[0].isBackgroundLayer == true) { 

var doc = app.activeDocument; 

var Path = doc.path; 

var Name = doc.name.replace(/\.[^\.]+$/, '');  

var Suffix = "-Photoshop"; 

var saveFile = File(Path + "/" + Name + Suffix + ".jpg"); 

SaveJPEG(saveFile, 10); 

function SaveJPEG(saveFile, jpegQuality){ 

jpgSaveOptions = new JPEGSaveOptions(); 

jpgSaveOptions.embedColorProfile = false; 

jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE; 

jpgSaveOptions.matte = MatteType.NONE; 

jpgSaveOptions.quality = jpegQuality; // 10

activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE); 

} else { 

activeDocument.close() 

}; 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 24, 2015 May 24, 2015

Copy link to clipboard

Copied

LATEST

After many many copy/paste trial/error I have finished script thanks to post #9. CS6 on Windows. Someone can clean code. Error log go to Windows/temp for easy clean.

Script convert layered images to pdf format which I think is better than psd and into source subfolder PDFs. PDF parameters is in the script.

Script convert non-layered images to jpg format and into source subfolder JPGs. JPG parameters is in the script.

1. Copy script "Layered PSD-TIF to layered PDF_Non-layered to JPG.jsx" to C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)\Presets\Scripts

2. Copy droplet "Layered PSD-TIF to layered PDF_Non-layered to JPG.exe" somewhere on pc.

3. Load actions set1 into action panel

4. Drop images onto droplet and wait.

download

http://1drv.ms/1LyMlGF

// 2015, use it at your own risk;

#target photoshop

if (app.documents.length > 0) {

var myDoc = app.activeDocument;

if (myDoc.layers.length == 1 && myDoc.layers[0].isBackgroundLayer == true) {

// Defines the active document that is opened

var docRef = app.activeDocument;

var imgName= docRef.name;

imgName = imgName.substr(0, imgName.length -4);

// Get name of Folder Path

var docFolder = docRef.fullName.parent;

var folderPath = docFolder.fsName;

// Create a sub-folder called PDFs in the working folder

var newPathFolder = new Folder( folderPath + "//JPGs/");

newPathFolder.create();

// Save Options for JPGs

var saveFile = new File( folderPath + "//JPGs/" + imgName + ".jpg");

SaveJPEG(saveFile, 10);

function SaveJPEG(saveFile, jpegQuality){

jpgSaveOptions = new JPEGSaveOptions();

jpgSaveOptions.embedColorProfile = false;

jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;

jpgSaveOptions.matte = MatteType.NONE;

jpgSaveOptions.quality = jpegQuality; // 10

activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);

}

} else {

// Defines the active document that is opened

var docRef = app.activeDocument;

var imgName= docRef.name;

imgName = imgName.substr(0, imgName.length -4);

// Get name of Folder Path

var docFolder = docRef.fullName.parent;

var folderPath = docFolder.fsName;

// Create a sub-folder called PDFs in the working folder

var newPathFolder = new Folder( folderPath + "//PDFs/");

newPathFolder.create();

// Save Options for PDFs

pdfFile = new File( folderPath + "//PDFs/" + imgName + "_photoshop.pdf")

pdfSaveOptions = new PDFSaveOptions()

pdfSaveOptions.layers = true;

pdfSaveOptions.embedColorProfile = false;

pdfSaveOptions.PDFStandard = PDFStandard.NONE;

pdfSaveOptions.PDFCompatibility = PDFCompatibility.PDF17;

pdfSaveOptions.preserveEditing=true;

pdfSaveOptions.embedThumbnail=true;

pdfSaveOptions.optimizeForWeb = true;

pdfSaveOptions.downSample = PDFResample.NONE;

pdfSaveOptions.encoding = PDFEncoding.PDFZIP;

pdfSaveOptions.colorConversion = false;

pdfSaveOptions.profileInclusionPolicy = false;

pdfSaveOptions.alphaChannels = true;

// set to NONE to allow PDF Security Options. Permission is for Printing only. A common password

// needs to be added as soon as the file is saved without typing it in all the time

docRef.saveAs(pdfFile, pdfSaveOptions, true, Extension.LOWERCASE);

docRef.close(SaveOptions.DONOTSAVECHANGES);

}

};

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines