Skip to content

Instantly share code, notes, and snippets.

View joonaspaakko's full-sized avatar
🍕
Pizza...

Joonas Pääkkö joonaspaakko

🍕
Pizza...
View GitHub Profile
@joonaspaakko
joonaspaakko / Select Next Layer (invisible or not).jsx
Last active February 26, 2024 21:46
Photoshop script that selects the next layer above or below even if it's not visible.
// Select Next Layer (invisible or not).jsx
// https://gist.github.com/joonaspaakko/048c9b58ccbb6e6f44c894bf4ce30b68
nextLayer('down');
// direction (↑): "up" or "above"
// direction (↓): "down" or "below"
function nextLayer( direction ) {
var doc = app.activeDocument;
@joonaspaakko
joonaspaakko / Export document for each layer inside selected group.jsx
Last active January 23, 2024 05:52
Photoshop script that saves the whole document for each top level layer inside the selected group.
// 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: https://user-images.githubusercontent.com/1164476/49152494-aef8af00-f31b-11e8-80ff-d774e3103eae.png
// https://gist.github.com/joonaspaakko/013a223e94ba0fb9a2a0
#target photoshop
@joonaspaakko
joonaspaakko / Illustrator convert to legacy.jsx
Last active December 30, 2023 10:48
Finds all Illustrator files from the input folder + its subfolders and converts them to an older version.
// https://gist.github.com/joonaspaakko/df2f9e31bdb365a6e5df
// 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.
/*
NOTE:
1. Makes the assumption that only one layer is selected (only really matters when going down)
2. Doesn't care if the adjacent layer is a group or not
*/
var options = {
direction: 'up',
loop: true,
};
@joonaspaakko
joonaspaakko / SaveTo (PS-AI).jsx
Last active December 10, 2023 01:49
SaveTo.jsx script (v.1.3.) for Photoshop and Illustrator. The idea is that it exports the work file and the production file at the same time, saving some time and effort.
// https://gist.github.com/joonaspaakko/b878d993b038b98b8ca78cc859916af4
// The idea is that it exports the work file and the production file (or a preview file) at the same time saving some time and effort.
// - This has been tested in Photoshop CC and Illustrator CC. It used to work in CS3, but I'm fairly sure I've changed the code enough at this point to break it for older versions.
// - Has a simple dialog where you can rename the file or leave it as it is.
// - If document has been saved, the script will suggest saving in the same path, otherwise it will default to what's set in the variable "newDocPath".
// - Photoshop saves .jpg and .psd
// - Illustrator saves .pdf and .ai and there's now the additional jpg option
// Mark all Audible library books ON THE CURRENT PAGE as finished or unfinished
// The script is basically a macro: it works by emulating a button click and just automating it for every single book
function markAs(config) {
config = config || {};
var i = 0;
var elements = $(config.finished ? ".mark-as-finished-button" : ".mark-as-unfinished-button");
var l = elements.length;
(function fn() {
const item = elements[i++];
$(item).find("button").click();
@joonaspaakko
joonaspaakko / Circulate foreground color.jsx
Last active October 11, 2023 16:45
The script switches foreground color to the next color in the "colors" variable each time you run the code.
#target photoshop
// https://gist.github.com/joonaspaakko/347c270f15bc1d11efe9
var colors = [ "#0033ff", "#9a3838", "#888888", "#a6ad1e" ];
function init() {
var read = tempFile.read(),
color = colors[ read ];
@joonaspaakko
joonaspaakko / Apply Master To Empty Pages.jsx
Last active August 3, 2023 21:21
Indesign script that applies a master page to all empty pages in the document.
// https://gist.github.com/joonaspaakko/f16b47be887a2058cd0c0ac6e7ab0343
// The script doesn't check for page items inside the current master.
// That means the current master could be filled with all kinds of graphics and this script considers it an empty page.
var master;
if (app.documents.length > 0) init();
function init() {
@joonaspaakko
joonaspaakko / Batch Mockup Smart Object Replacement.jsx
Created March 13, 2023 20:11
Batch Mockup Smart Object Replacement.jsx (random lengthy output)
// v.1.6.
// Batch Mockup Smart Object Replacement.jsx
// You'll need to incplude this file to another script file:
// #include "../script/Batch Mockup Smart Object Replacement.jsx"
// Check the example folders for a few real world examples.
// Minimal settings
/*
@joonaspaakko
joonaspaakko / Select Child Layers.jsx
Last active April 27, 2023 12:42
Select Child Layers.jsx Photoshop Script - Selects the first level of layers inside the currently active group.
// https://gist.github.com/joonaspaakko/1add5c6a905216740c9c922a657636e1
#target photoshop
if ( app.activeDocument.activeLayer.typename == 'LayerSet' ) {
app.activeDocument.suspendHistory( "Select Child Layers.jsx", "init();" );
}
function init() {
var doc = app.activeDocument;