Here you\'ll find tutorials that don\'t belong to either of the above categories. This is the place for the most extraordinary materials.  Home Photoshop Miscellaneous Document Metadata

Document Metadata


Document MetadataIf you are new to scripting for Photoshop, please view our Photoshop Scripting Basics tutorial for an introduction to Photoshop scripting and a few exercises about basic JavaScript.

1. The first thing we need to do is check to see if there is an document. To do this, we'll check to see if the current document has a length. If it doesn't, it obviously means that there are no opened documents and the script will do nothing instead of giving an error.

if (documents.length > 0) {

}


2. Now we can enter in the metadata. Type in the following lines and fill in the settings you would like to use inside the quotations (""):

if (documents.length > 0) {
activeDocument.info.author = "Denny Tang";
activeDocument.info.title = "My Photoshop File";
activeDocument.ownerURL = "http://www.fotofects.com";
activeDocument.category = "Photoshop Scripting";
activeDocument.credit = "Denny Tang";
activeDocument.info.jobName = "Metadata";
activeDocument.info.keywords = ['photoshop', 'scripting', 'fotofects'];
activeDocument.info.city = "Vancouver";
activeDocument.info.provinceState = "BC";
activeDocument.info.country = "Canada";

}


3. Save the script and run it inside Photoshop. View your File Info (Ctrl+Alt+I) to ensure that the changes are being made.

4. If you look at the script, you'll notice that the "activeDocument" property gets repeated a lot. A good practice in programming is to optimize the code. We'll create a variable that will hold the "activeDocument" property.

if (documents.length > 0) {
var doc = activeDocument;
activeDocument.info.author = "Denny Tang";
activeDocument.info.title = "My Photoshop File";
activeDocument.ownerURL = "http://www.fotofects.com";
activeDocument.category = "Photoshop Scripting";
activeDocument.credit = "Denny Tang";
activeDocument.info.jobName = "Metadata";
activeDocument.info.keywords = ['photoshop', 'scripting', 'fotofects'];
activeDocument.info.city = "Vancouver";
activeDocument.info.provinceState = "BC";
activeDocument.info.country = "Canada";
}


5. Now everytime we want to use the activeDocument property, we only need to type in "doc". Scripts usually use the activeDocument propertly many times so consider adding it to your other codes.

if (documents.length > 0) {
var doc = activeDocument;
doc.info.author = "Denny Tang";
doc.info.title = "My Photoshop File";
doc.ownerURL = "http://www.fotofects.com";
doc.category = "Photoshop Scripting";
doc.credit = "Denny Tang";
doc.info.jobName = "Metadata";
doc.info.keywords = ['photoshop', 'scripting', 'fotofects'];
doc.info.city = "Vancouver";
doc.info.provinceState = "BC";
doc.info.country = "Canada";
}


6. If you will be changing the metadata more than once, it's a good idea to create a function out of it.

function setMetaData() {
if (documents.length > 0) {
var doc = activeDocument;
doc.info.author = "Denny Tang";
doc.info.title = "My Photoshop File";
doc.ownerURL = "http://www.fotofects.com";
doc.category = "Photoshop Scripting";
doc.credit = "Denny Tang";
doc.info.jobName = "Metadata";
doc.info.keywords = ['photoshop', 'scripting', 'fotofects'];
doc.info.city = "Vancouver";
doc.info.provinceState = "BC";
doc.info.country = "Canada";
}
}
setMetaData();



Author's URL: FotoFects
Thank you for voting.
Rate this Materials:
Bad 
1 2 3 4 5 Excellent
print this page subscribe to newsletter subscribe to rss

Advance your current skills or acquire new skills in Photoshop by creating projects using our step-by-step tutorials. More Tutorials: Most Popular Materials | Fresh Materials | TutorialKit New Photoshop Tutorials

Add comments to "Document Metadata"

Only registered users can write comment

Reader's comments