🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #2559

LabelGraphics Script

#2559
From: nelgom
Date: Wed, 10 Dec 2008 22:27
87 lines
4494 bytes
Hi Everyone, I don't know much about scripting so I'm hoping someone can help me. I'm trying to modify the LabelGraphics script to capture the "Date Created" field. I have tons of images that I need to organize based on their date of creation but I need to see the date with the image in the layout (long story). Anyway, I have tried to change XMP Author to Date Created but nothing. Below is the script as it came from Adobe. Any help will be greatly appreciated.

//LabelGraphics.jsx
//An InDesign CS3 JavaScript
/*
@@@BUILDINFO@@@ "LabelGraphics.jsx" 1.0.0 14-September-2006
* / //Adds labels to the graphics in the active document.
main();
function main(){
	if(app.documents.length != 0){
		if(app.documents.item(0).allGraphics.length != 0){
			myDisplayDialog();
		}
		else{
			alert("Document contains no graphics.");
		}
	}
	else{
		alert("Please open a document and try again.");
	}
}
function myDisplayDialog(){
	var myLabelWidth = 100;
	var myStyleNames = myGetParagraphStyleNames();
	var myDialog = app.dialogs.add({name:"LabelGraphics"});
	with(myDialog.dialogColumns.add()){
		//Label type
		with(dialogRows.add()){
			with(dialogColumns.add()){
				staticTexts.add({staticLabel:"Label Type", minWidth:myLabelWidth});
			}
			with(dialogColumns.add()){
				var myLabelTypeDropdown = dropdowns.add({stringList:["File name", "File path", "XMP description", "XMP author"], selectedIndex:0});
			}
		}
		//Text frame height
		with(dialogRows.add()){
			with(dialogColumns.add()){
				staticTexts.add({staticLabel:"Label Height", minWidth:myLabelWidth});
			}
			with(dialogColumns.add()){
				var myLabelHeightField = measurementEditboxes.add({editValue:24});
			}
		}
		//Text frame offset
		with(dialogRows.add()){
			with(dialogColumns.add()){
				staticTexts.add({staticLabel:"Label Offset", minWidth:myLabelWidth});
			}
			with(dialogColumns.add()){
				var myLabelOffsetField = measurementEditboxes.add({editValue:0});
			}
		}
		//Style to apply
		with(dialogRows.add()){
			with(dialogColumns.add()){
				staticTexts.add({staticLabel:"Label Style", minWidth:myLabelWidth});
			}
			with(dialogColumns.add()){
				var myLabelStyleDropdown = dropdowns.add({stringList:myStyleNames, selectedIndex:0});
			}
		}
	}
	var myResult = myDialog.show();
	if(myResult == true){
		var myLabelType = myLabelTypeDropdown.selectedIndex;
		var myLabelHeight = myLabelHeightField.editValue;
		var myLabelOffset = myLabelOffsetField.editValue;
		var myLabelStyle = myStyleNames[myLabelStyleDropdown.selectedIndex];
		myDialog.destroy();
		var myOldXUnits = app.documents.item(0).viewPreferences.horizontalMeasurementUnits;
		var myOldYUnits = app.documents.item(0).viewPreferences.verticalMeasurementUnits;
		app.documents.item(0).viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;
		app.documents.item(0).viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
		myAddLabels(myLabelType, myLabelHeight, myLabelOffset, myLabelStyle);
		app.documents.item(0).viewPreferences.horizontalMeasurementUnits = myOldXUnits;
		app.documents.item(0).viewPreferences.verticalMeasurementUnits = myOldYUnits;
	}
	else{
		myDialog.destroy();
	}
}
function myAddLabels(myLabelType, myLabelHeight, myLabelOffset, myLabelStyleName){
	var myDocument = app.documents.item(0);
	var myGraphics = myDocument.allGraphics;
	myLabelStyle = myDocument.paragraphStyles.item(myLabelStyleName);
	for(var myCounter = 0; myCounter < myGraphics.length; myCounter++){ 		myAddLabel(myDocument, myGraphics[myCounter], myLabelType, myLabelHeight, myLabelOffset, myLabelStyle); 	} } function myAddLabel(myDocument, myGraphic, myLabelType, myLabelHeight, myLabelOffset, myLabelStyle){ 	var myLabel; 	var myLink = myGraphic.itemLink; 	//Create the label layer if it does not already exist. 	var myLabelLayer = myDocument.layers.item("labels"); 	try{ 		myLabelLayer.name; 	} 	catch (myError){ 		myL
Technical Details
Message-ID: <59b73ca9.-1@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newshub.sdsu.edu!webcrossing

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,f2293e54402292c8,start
X-Google-Attributes: gidf939a,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: nelgom@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: LabelGraphics Script
Message-ID: <59b73ca9.-1@webcrossing.la2eafNXanI>
Date: Wed, 10 Dec 2008 14:27:27 -0800
Lines: 121
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit