Skip to content

Instantly share code, notes, and snippets.

@cg-method
Created August 1, 2019 22:13
Show Gist options
  • Save cg-method/e0fb5799dd38a3ae13eb7ee7c5ec838c to your computer and use it in GitHub Desktop.
Save cg-method/e0fb5799dd38a3ae13eb7ee7c5ec838c to your computer and use it in GitHub Desktop.
【Photoshop】画像アセット用にリネーム.jsx
var doc = app.activeDocument;
doc.activeLayer = doc.layers.getByName("リネーム");
var fileName = doc.name;
var fileName = baseName(fileName);
//レイヤーリネーム
doc.activeLayer.name = fileName + ".png" + "," + "32x32 fileName" + ".png";
//保存して閉じる
doc.save();
doc.close();
//拡張子を抜く
function baseName(str) {
var base = new String(str).substring(str.lastIndexOf('/') + 1);
if (base.lastIndexOf(".") != -1)
base = base.substring(0, base.lastIndexOf("."));
return base;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment