Skip to content

Instantly share code, notes, and snippets.


Joonas Pääkkö joonaspaakko

View GitHub Profile
joonaspaakko / Export document for each layer inside selected group - scale doc 10x.jsx
Last active May 12, 2022
Export document for each layer inside selected group - scale doc 10x
View Export document for each layer inside selected group - scale doc 10x.jsx
// Name: Export document for each layer inside selected group.jsx
// Formerly: Export Layers Inside Selected Group.jsx
// Description: Photoshop script that saves the whole document for each top level layer inside the selected group.
// Image example:
#target photoshop
joonaspaakko / Read and write text.jsx
Created Oct 11, 2021
Read and write text example in Adobe extendscript
View Read and write text.jsx
// In this demo:
// 1. I first prep the output file path
// 2. Then write the text file: "current date and time + some placeholder text"
// - As long as you don't change the path, it gets written next to this script file.
// 3. Then read the text file
// 4. And finally trigger alert() to show the text that was written.
// - At the top it shows each line as an array
// - And below that it just shows the full text as it was written.
View Illustrator convert to pdf and legacy.jsx
// Finds all .ai files from the input folder + its subfolders and converts them to the version given below in a variable called "targetVersion"
// Tested in Illustrator cc 2014 (Mac)
// Didn't bother to do a speed test with my macbook air...
#target illustrator
// If set to false, a new file will be written next to the original file.
View Indesign Script - Get pageitem stacking index & select item based on the same ruleset.jsx
var selection = app.selection[0];
var zIndex = getStackingIndex( selection, true );
$.writeln( zIndex );
// Since the last parameter is set to false, this selectPageItem() mirrors the selection
// - If first item is selected when the script is run, the last one will be
// selected when the script is done.
selectPageItem( selection.parentPage, zIndex, false );
joonaspaakko / Select All Layers.jsx
Last active Dec 20, 2019
Photoshop script for selecting all layers, including the background layer.
View Select All Layers.jsx
function selectAllLayers() {
// Select all layers (doesn't include Background)
try {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
desc.putReference( charIDToTypeID('null'), ref );
executeAction( stringIDToTypeID('selectAllLayers'), desc, DialogModes.NO );
View Add leading & trailing space to a specific character style.jsx
// Set true to "normalize" the character styled text = no extra leading & trailing spaces
var removeSpace = false;
app.findTextPreferences = null;
app.changeTextPreferences = null;
var findPref = app.findTextPreferences;
var changePref = app.changeTextPreferences;
findPref.appliedCharacterStyle = 'yellow-background';
joonaspaakko / Select Next Layer (invisible or not).jsx
Last active Apr 23, 2019
Photoshop script that selects the next layer above or below even if it's not visible.
View Select Next Layer (invisible or not).jsx
// Select Next Layer (invisible or not).jsx
// direction (↑): "up" or "above"
// direction (↓): "down" or "below"
function nextLayer( direction ) {
var doc = app.activeDocument;
joonaspaakko / Compare Selected Comps.jsx
Last active Dec 11, 2020
Photoshop script for comparing selected layer comps. The script arranges layer comps on a new document for your viewing pleasure.
View Compare Selected Comps.jsx
// Version 1.1.
// Compare Selected Comps.jsx
// #########
// Changelog
// #########
// v.1.1.
// - Tested in Photoshop CC 2019
joonaspaakko / Page Numbers To Percentages.jsx
Last active Sep 12, 2021
Indesign script for converting page numbers to percentages.
View Page Numbers To Percentages.jsx
// Version.1.0.
// Page Numbers To Percentages.jsx
// You may want to save before running the script. Every single
// time you run the script, all text frames that are inside a
// master page or nested master pages will be torn out (overridden).
// The script assumes the starting point is this:
// 1. You have a designated layer for the page numbers (Layer name defined below↓).
joonaspaakko / Save PNG next to PSD (Incremental numbers)
Created Mar 12, 2019
If the file hasn't already been saved as a PSD, the script will prompt you to do that because it relies on that path for all the exports.
View Save PNG next to PSD (Incremental numbers)
#target photoshop
var savePSD = false; // If set true the psd document is saved every time the script runs...
var folderName = ' (Frames)';
try {
var doc = app.activeDocument;
var fileExists = false;