This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Remove Filename Extension (4 different methods) */ | |
var baseName = app.activeDocument.name.split('.')[0]; | |
// or for multiple period characters | |
var extensionIndex = activeDocument.name.lastIndexOf("."); | |
if (extensionIndex != -1) { | |
var baseName = activeDocument.name.substr(0, extensionIndex); | |
alert(baseName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Save the current ruler units and set to pixels | |
var savedRuler = app.preferences.rulerUnits; | |
app.preferences.rulerUnits = Units.PIXELS; | |
// Do stuff... | |
// Restore the ruler units | |
app.preferences.rulerUnits = savedRuler; | |
// Save the current dialog display settings | |
var savedDisplayDialogs = app.displayDialogs; | |
app.displayDialogs = DialogModes.NO; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Start Open Document Error Check - Part A: If */ | |
if (app.documents.length > 0) { | |
/* Main Code Start */ | |
alert('Do something here!'); | |
/* Main Code Finish */ | |
} | |
/* Finish Open Document Error Check - Part A: If */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!documents.length) { | |
alert('There are no documents open.', 'No Document'); | |
} else { | |
alert('You have a document open!'); | |
} | |
// or | |
if (app.documents.length > 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Remove ' px' from document width and height | |
app.preferences.rulerUnits = Units.PIXELS; | |
var w = app.activeDocument.width.toString().replace(' px', ''); | |
var h = app.activeDocument.height.toString().replace(' px', ''); | |
//or | |
var w = app.activeDocument.width.value; | |
var h = app.activeDocument.height.value; | |
//or |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// remove all paths | |
app.activeDocument.pathItems.removeAll(); | |
// remove all alphas | |
app.activeDocument.channels.removeAll(); | |
// remove all layercomps | |
app.activeDocument.layerComps.removeAll(); | |
// remove all color samplers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Move the current layer in 5px from the right and down 5px from the top | |
app.activeDocument.activeLayer.translate( -5, 5 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.doAction("Molten Lead","Default Actions.atn"); | |
// or | |
var actionName = "Molten Lead"; // Action to run | |
var actionSet = "Default Actions.atn"; // Action set to run | |
app.doAction(actionName,actionSet); | |
// or |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Deselect All Layers | |
// forums.adobe.com/message/5204655#5204655 - Michael L Hale | |
app.runMenuItem(stringIDToTypeID('selectNoLayers')); | |
// Or... | |
// Deselect All Layers (AM Code Through Clean SL) | |
selectNoLayers(); | |
function selectNoLayers() { | |
var c2t = function (s) { |
OlderNewer