Skip to content

Instantly share code, notes, and snippets.

@monsieuroeuf
Created November 16, 2025 06:40
Show Gist options
  • Select an option

  • Save monsieuroeuf/808569ba3d9a0538b4db0b44d1fd9e92 to your computer and use it in GitHub Desktop.

Select an option

Save monsieuroeuf/808569ba3d9a0538b4db0b44d1fd9e92 to your computer and use it in GitHub Desktop.
For Adobe After Effects, Mac only. Rename selected layers based on the clipboard contents.
//@target aftereffects
/**
* 2025-04-07
* @description This script renames selected layers in the active composition based on the clipboard content.
*/
(function renameFromClipboard() {
var proj = app.project;
app.beginUndoGroup("renameFromClipboard");
// const newNames = app.getenv("argumentative")
var newNames = readFromClipboard().split("\n");
if (newNames.length !== proj.selection.length) {
alert("The number of names in the clipboard does not match the number of selected layers.");
return;
}
var selectedItemsSorted = proj.selection.sort(function (a, b) {
return a.name < b.name ? -1 : 1;
});
for (var i = 0; i < selectedItemsSorted.length; i++) {
var item = selectedItemsSorted[i];
if (item instanceof CompItem) {
item.name = newNames[i];
}
}
function readFromClipboard() {
var cmd = 'pbpaste';
return system.callSystem(cmd);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment