Skip to main content
May 13, 2019
Question

[Slice tool] How to select all slices in one shot

  • May 13, 2019
  • 5 replies
  • 3470 views

Hello everyone.

Apparently that possibility is no longer available after a specific version of Photoshop CC 2015 and I'm wondering if there is another way to get the same result without too much work and stress.

Let's assume that we have a cube 6x6 that I want to slice in single pictures, for some reason the lines on the pictures are not in the same position as the ones created by Photoshop so I will need to move them.

In Photoshop CC 2015 after you do right click, slice selection, put your preference and click ok, all the slices are already selected and if you move one of the lines created by Photoshop you will move for the entire slice selection (example in attachment)

Something similar can be obtained in the new version of Photoshop if you use the Slice Tool Selection, hold Shift and click in each slice (which is taking a lot of time).

Anyone have an idea how to solve/bypass this problem?

Thank you

5 replies

puciak1
Participant
April 3, 2026

I finally found the solution. Here a script (jsx):

#target photoshop

// Helper functions for converting string/char IDs used in Photoshop Action Manager API
var s2t = stringIDToTypeID,
c2t = charIDToTypeID;

// Get all slices from the active document
var ref = new ActionReference();
ref.putProperty(s2t('property'), s2t('slices'));
ref.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));

// Retrieve slice list from the document
var slices = executeActionGet(ref)
.getObjectValue(s2t('slices'))
.getList(s2t('slices'));

// Loop through all slices
for (var i = 0; i < slices.count; i++) {

var slice = slices.getObjectValue(i);
var bounds = slice.getObjectValue(s2t('bounds'));

// Extract slice boundaries
var left = bounds.getInteger(s2t('left'));
var top = bounds.getInteger(s2t('top'));
var right = bounds.getInteger(s2t('right'));
var bottom = bounds.getInteger(s2t('bottom'));

// Calculate the center point of the slice (click point)
var x = (left + right) / 2;
var y = (top + bottom) / 2;

// Create a selection action (simulate clicking a slice)
var desc = new ActionDescriptor();
var refSel = new ActionReference();

// Target slice class for selection
refSel.putClass(s2t('slice'));
desc.putReference(c2t('null'), refSel);

// Define click point coordinates
var pointDesc = new ActionDescriptor();
pointDesc.putUnitDouble(c2t('Hrzn'), c2t('#Pxl'), x);
pointDesc.putUnitDouble(c2t('Vrtc'), c2t('#Pxl'), y);

desc.putObject(c2t('At '), c2t('Pnt '), pointDesc);

// First slice is normal select, others are added with SHIFT (add to selection)
desc.putBoolean(s2t('addToSelection'), i !== 0);

// Execute the selection action without showing dialogs
executeAction(c2t('slct'), desc, DialogModes.NO);
}

Put it into your Adobe Photoshop\Presets\Scripts directory as for example “Select All Slices.jsx”. After restart it should appear in File/Scripts.

puciak1
Participant
April 3, 2026

And here is bonus script for selecting slices, which overlap with rectangular selection. First select rectangular selection tool and make a selection. Then run the script.
 

#target photoshop

var s2t = stringIDToTypeID;
var c2t = charIDToTypeID;

// Get current rectangle selection bounds
var currentSelection = getCurrentSelectionBounds();

if (currentSelection) {
// Switch to Slice Select Tool
selectSliceSelectTool();

// Get all slices from document
var slices = getAllSlices();

if (slices.length > 0) {
// Select slices that overlap with the rectangle selection
selectOverlappingSlices(slices, currentSelection);
}

// Clear the original rectangle selection
clearSelection();
}

// ------------------------------------------------------------
// Gets the bounds of the current selection
function getCurrentSelectionBounds() {
try {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putProperty(s2t('property'), s2t('selection'));
ref.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
desc.putReference(s2t('null'), ref);

var selectionDesc = executeAction(s2t('get'), desc, DialogModes.NO);
var selectionBounds = selectionDesc.getObjectValue(s2t('selection'));

if (!selectionBounds.hasKey(s2t('top'))) return null;

return {
left: selectionBounds.getDouble(s2t('left')),
top: selectionBounds.getDouble(s2t('top')),
right: selectionBounds.getDouble(s2t('right')),
bottom: selectionBounds.getDouble(s2t('bottom'))
};
} catch(e) {
return null;
}
}

// ------------------------------------------------------------
// Switches to the Slice Select Tool
function selectSliceSelectTool() {
try {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass(s2t('sliceSelectTool'));
desc.putReference(s2t('null'), ref);
executeAction(s2t('select'), desc, DialogModes.NO);
} catch(e) {
// Tool may already be active - ignore error
}
}

// ------------------------------------------------------------
// Retrieves all slices from the active document
function getAllSlices() {
var slices = [];

try {
// Get document descriptor
var docRef = new ActionReference();
docRef.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
var docDescriptor = executeActionGet(docRef);

// Get slices list from document
var slicesDescriptors = docDescriptor
.getObjectValue(s2t('slices'))
.getList(s2t('slices'));

// Iterate through all slices
for (var i = 0; i < slicesDescriptors.count; i++) {
var currentSlice = slicesDescriptors.getObjectValue(i);
var sliceBounds = currentSlice.getObjectValue(s2t('bounds'));

// Get bounds as integers (Photoshop stores slice coordinates as integers)
var left = sliceBounds.getInteger(s2t('left'));
var top = sliceBounds.getInteger(s2t('top'));
var right = sliceBounds.getInteger(s2t('right'));
var bottom = sliceBounds.getInteger(s2t('bottom'));

// Get optional name (use default if not present)
var name = "Slice " + i;
if (currentSlice.hasKey(s2t('name'))) {
name = currentSlice.getString(s2t('name'));
}

// Get slice ID
var sliceId = currentSlice.getInteger(s2t('sliceID'));

slices.push({
index: i,
id: sliceId,
name: name,
left: left,
top: top,
right: right,
bottom: bottom
});
}
} catch(e) {
// Silently fail - no slices found
}

return slices;
}

// ------------------------------------------------------------
// Checks if two rectangles overlap (partial or full)
function rectsOverlap(rect1, rect2) {
return !(rect1.right <= rect2.left ||
rect1.left >= rect2.right ||
rect1.bottom <= rect2.top ||
rect1.top >= rect2.bottom);
}

// ------------------------------------------------------------
// Selects slices that overlap with the given selection bounds
function selectOverlappingSlices(slices, selectionBounds) {
// Find slices that overlap with the selection
var overlappingSlices = [];
for (var i = 0; i < slices.length; i++) {
var slice = slices[i];
var sliceBounds = {
left: slice.left,
top: slice.top,
right: slice.right,
bottom: slice.bottom
};

if (rectsOverlap(sliceBounds, selectionBounds)) {
overlappingSlices.push(slice);
}
}

// Select overlapping slices
for (var j = 0; j < overlappingSlices.length; j++) {
var slice = overlappingSlices[j];

// Calculate center point of the slice (click position)
var x = (slice.left + slice.right) / 2;
var y = (slice.top + slice.bottom) / 2;

// Simulate click on slice
var desc = new ActionDescriptor();
var refSel = new ActionReference();
refSel.putClass(s2t('slice'));
desc.putReference(c2t('null'), refSel);

var pointDesc = new ActionDescriptor();
pointDesc.putUnitDouble(c2t('Hrzn'), c2t('#Pxl'), x);
pointDesc.putUnitDouble(c2t('Vrtc'), c2t('#Pxl'), y);
desc.putObject(c2t('At '), c2t('Pnt '), pointDesc);

// First slice = normal select, subsequent slices = SHIFT+click (add to selection)
desc.putBoolean(s2t('addToSelection'), j !== 0);

executeAction(c2t('slct'), desc, DialogModes.NO);
}
}

// ------------------------------------------------------------
// Clears the current selection (deselect all)
function clearSelection() {
try {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putProperty(s2t('channel'), s2t('selection'));
desc.putReference(s2t('null'), ref);
desc.putEnumerated(s2t('to'), s2t('ordinal'), s2t('none'));
executeAction(s2t('set'), desc, DialogModes.NO);
} catch(e) {
// Ignore errors if no selection to clear
}
}

 

Whit_Serenity
Inspiring
March 30, 2023

Hey @1695762, I think the silence is due to no such feature existing. 😕😕 As you may be aware, Adobe has been trying to deprecate this tool set for years but their attempts at replacement never quite get to the same level of functionality. Thus, it remains. Pretty similar to the Lightroom situation.

 

However, I did just discover one partially-helpful fallback:

  1. Take note of your PSD dimensions
  2. Select the Crop tool and make sure the 'delete pixel data' toggle is turned OFF.
  3. Crop your canvas so that all of the offending Slices are removed.
  4. Rezize your Canvas back to its original dimensions.

 

After doing this, the Slices that were outside the revised boundaries will be gone and everything else will remain. This saved me at least a few minutes of tedious Shift-clicking. Good luck!

May 16, 2019

up

May 14, 2019

Hello, someone can suggest a solution?

Thank you

Dr. Ayman Raafat Ph.D
Inspiring
May 13, 2019

hello , you can choose the slice select tool , then using shift while selecting the slices

best

Ayman

May 13, 2019

Hello, thank you for your response. Unfortunately from what I understood, you just provided me a solution that I already wrote about in my post: "Something similar can be obtained in the new version of Photoshop if you use the Slice Tool Selection, hold Shift and click in each slice (which is taking a lot of time).".

What I would like to know is if I can make this process faster or bypass it, because with a lot of slices it takes a lot of time to select all of them.

Thank you!