• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Add suffixes to files

New Here ,
Jun 05, 2013 Jun 05, 2013

Copy link to clipboard

Copied

Hi

I wanted to do the following steps with Actions, but I am unable to do it - maybe because of intellectual or technical limitation. I hope you guys here can help:

I am making icons for a desktop application, and due to how the code is written I need to save each new icon in three almost similar versions

I have an original file in e.g. 16x16 PNG - lets call it "Example.png"

This file needs to be saved first as "Example_16_n_p.png"

Then needs to be saved as "Example_16_h_p.png"

and then have its Mode changed to 'grayscale' and have the opacity changed in the layers menu to 60%, and then saved as "Example_16_d_p.png"

(For those who wonder why: the suffixes is for the Java application to understand: the size of the icon, if the file is used for n=neutral, h=hover, d=disabled, and finally that it should read it as a p=png)

((some of this code is a little redundant as e.g. n and h files are completely the same, but company standards are company standards 🙂 ))

I'd like to just point to a folder where my original files are stored, and have the resulting files saved in a subfolder called e.g. "Commit icons" - not touching the originals.

Anyone?

/Loopy

TOPICS
Actions and scripting

Views

616

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Jun 05, 2013 Jun 05, 2013

Please try this...

#target photoshop

main();

function main(){

var inFolder = Folder.selectDialog("Please select folder to process");

var fileList = inFolder.getFiles("*.png");

if(fileList.length == 0 ) return;

var outputFolder = Folder (inFolder+"/Commit icons");

if(!outputFolder.exists) outputFolder.create();

for(var a in fileList){

var png = open(fileList);

var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');

var saveFile = File(outputFolder + "/" + Name + "_16_n_p.png");

SavePNG(saveFile);

saveFil

...

Votes

Translate

Translate
Adobe
Valorous Hero ,
Jun 05, 2013 Jun 05, 2013

Copy link to clipboard

Copied

Please try this...

#target photoshop

main();

function main(){

var inFolder = Folder.selectDialog("Please select folder to process");

var fileList = inFolder.getFiles("*.png");

if(fileList.length == 0 ) return;

var outputFolder = Folder (inFolder+"/Commit icons");

if(!outputFolder.exists) outputFolder.create();

for(var a in fileList){

var png = open(fileList);

var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');

var saveFile = File(outputFolder + "/" + Name + "_16_n_p.png");

SavePNG(saveFile);

saveFile = File(outputFolder + "/" + Name + "_16_h_p.png");

SavePNG(saveFile);

activeDocument.activeLayer.opacity=60;

activeDocument.changeMode(ChangeMode.GRAYSCALE);

saveFile = File(outputFolder + "/" + Name + "_16_d_p.png");

SavePNG(saveFile);

app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

    }

};

function SavePNG(saveFile){

    pngSaveOptions = new PNGSaveOptions();

activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE);

};

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 05, 2013 Jun 05, 2013

Copy link to clipboard

Copied

LATEST

WOW. thanks Paul

Worked like a charm!!

You're the Man!

/L

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines