Skip to content

Instantly share code, notes, and snippets.

View MarshySwamp's full-sized avatar

MarshySwamp

View GitHub Profile
@MarshySwamp
MarshySwamp / Open Multiple Selected Files.jsx
Created October 24, 2023 20:25
Open Multiple Selected Files
var selectFile = File.openDialog("Please select the file/s:", Multiselect = true);
for (var i = 0; i < selectFile.length; i++) {
var openFiles = app.open(File(selectFile[i]));
}
// or
var aFile = selectFile(true);
for (var i = 0; i < aFile.length; i++) {
open(File(aFile[i]));
@MarshySwamp
MarshySwamp / exiftool all metadata to csv.txt
Created July 2, 2023 05:47
ExifTool All Metadata to CSV
exiftool -r -all -csv '/Users/loggedinusername/Desktop/test' > '/Users/loggedinusername/Desktop/metadata-out.csv'
@MarshySwamp
MarshySwamp / Select-Clipping-Mask-Base-Layer.jsx
Last active September 20, 2022 10:35
Select Clipping Mask Base Layer
selectGroupedBaseLayer();
function selectGroupedBaseLayer() {
// Stephen Marsh, v2.0 - 20th September 2022
// Works with a visible or invisible clipping mask base layer
for (i = 0; i < activeDocument.layers.length; i++) {
if (activeDocument.activeLayer.grouped === true) {
//alert("Grouped, move on...");
toggleLayerVisibility(true);
selectForwardORBackwardLayer(false, "backwardEnum");
@MarshySwamp
MarshySwamp / Color-Picker-GUI.jsx
Last active April 9, 2022 23:29
Color Picker GUI
// Foreground
app.showColorPicker(true);
// or
// Background
app.showColorPicker(false);
@MarshySwamp
MarshySwamp / Counter.jsx
Created April 4, 2022 01:12
Counter for saved files
/* Add an incremental counter to report on the count of files saved */
// Set the file save counter (outside the for loop...)
var counter = 0;
// fileList not included in this example
for (var i = 0; i < fileList.length; i++) {
var doc = open(fileList[i]);
@MarshySwamp
MarshySwamp / Folder Name to String.jsx
Created March 11, 2022 11:18
Remove %20 from folder name text string
/* Remove %20 character from folder name via RegEx */
var inputFolder = Folder.selectDialog("Select the input folder:");
alert("Original Folder Path:" + "\r" + inputFolder);
// Full path fsName + RegEx
var inputFSname = inputFolder.fsName.replace(/(?:.+\/)(.+)$/, '$1');;
alert("FS Name:" + "\r" + inputFSname.toSource());
// Remove %20 space code via regex
@MarshySwamp
MarshySwamp / Elliptical Select All.jsx
Created January 10, 2022 03:33
An elliptical version of the standard rectangular select all command, it obviously does not select all as it is an ellipse, but you get the idea...
ellipticalSelectAll(0, 0, app.activeDocument.height.value, app.activeDocument.width.value, true);
function ellipticalSelectAll(top, left, bottom, right, antiAlias) {
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
var reference = new ActionReference();
reference.putProperty( s2t( "channel" ), s2t( "selection" ));
@MarshySwamp
MarshySwamp / addMask.jsx
Last active January 10, 2022 03:30
Add a "reveal all" or "hide all" layer mask
addMask("reveallAll");
function addMask(maskVisibility) {
// maskVisibility = "revealAll" or "hideAll"
var c2t = function (s) {
return app.charIDToTypeID(s);
};
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
@MarshySwamp
MarshySwamp / maskSelection.jsx
Created January 6, 2022 00:58
Add a "reveal" or "hide" selection based layer mask
maskSelection("revealSelection");
function maskSelection(maskParameter) {
// Parameter = "revealSelection" or "hideSelection"
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var reference = new ActionReference();
descriptor.putClass( s2t( "new" ), s2t( "channel" ));
@MarshySwamp
MarshySwamp / quickMask.jsx
Last active September 2, 2022 12:46
Quick Mask Mode
activeDocument.quickMaskMode = true;
activeDocument.quickMaskMode = false;
//or
quickMask("set"); // or "clearEvent"
function quickMask(qmOpt) {
var s2t = function (s) {
return app.stringIDToTypeID(s);