Add suffixes to files

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

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[a]);
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);

Similar Messages

  • Combine "Save As" with suffix for file's name

    I have 600x600px file named "ABC". I want to save this file in three versions within 1 folder which different to original folder:
    ver1   600x600px   name  ABC_1  in JPEG
    ver2   300x300px   name  ABC_2  in PSD
    ver 3  300x300px   name ABC_3   in JPEG.
    I can do this with Save As command but cannot add suffix.  I can add suffix with a script but I dont know how to create a UI interface to choose file type and file address like we do with Save As . Thanks in advanced for your script's  help .

    Try this:
    #target photoshop  
    app.preferences.rulerUnits = Units.PIXELS;    
    var targetFolder = new Folder('/c/');
    var saveFolder = new Folder('/c/');
    var docRef;
    var jpgOptions = new JPEGSaveOptions();
    jpgOptions.quality = 10;
    var psdOptions = new PhotoshopSaveOptions();
    psdOptions.layers = true;    
    var winFiles = app.windowsFileTypes;
    var macFiles = app.macintoshFileTypes;
    var dlg = new Window('dialog','Process Images');
        dlg.targetGp = dlg.add('group');
        dlg.targetGp.sTxt = dlg.targetGp.add('statictext',undefined,'Target Folder');
        dlg.targetGp.btn = dlg.targetGp.add('button',undefined,targetFolder.fsName);
            dlg.targetGp.btn.size = [500,20];
            dlg.targetGp.btn.onClick = function(){
                targetFolder = Folder.selectDialog ('Select a target folder');
                dlg.targetGp.btn.text = targetFolder.fsName;}
        dlg.folderGp = dlg.add('group');
        dlg.folderGp.sTxt = dlg.folderGp.add('statictext',undefined,'Save Folder');
        dlg.folderGp.btn = dlg.folderGp.add('button',undefined,saveFolder.fsName);
            dlg.folderGp.btn.size = [500,20];
            dlg.folderGp.btn.onClick = function(){
                saveFolder = Folder.selectDialog ('Select a save folder')
                dlg.folderGp.btn.text = saveFolder.fsName};
        dlg.btnGp = dlg.add('group');
        dlg.btnGp.okay = dlg.btnGp.add('button',undefined,'Okay');
        dlg.btnGp.cancel = dlg.btnGp.add('button',undefined,'Cancel');    
        dlg.btnGp.okay.onClick = function(){
            if(!targetFolder.exists){alert('The target folder selected does not exist.')}
            if(!saveFolder.exists){alert('The save folder selected does not exist.')}
            if(targetFolder.exists && saveFolder.exists){
                dlg.close();
                runProg()}
        dlg.btnGp.cancel.onClick = function(){
            dlg.close()};    
        dlg.show();
    function runProg (){
        var fileList = targetFolder.getFiles ()
        var filesToUse = new Array()
        for (var i=0;i<fileList.length;i++){
            if(IsFileOneOfThese( fileList[i], winFiles )){filesToUse.push(fileList[i])}
            else if(IsFileOneOfTheseTypes( fileList[i], macFiles )){filesToUse.push(fileList[i])}
            };//end loop 1
        for (var i=0;i<filesToUse.length;i++){   
            try{
                 docRef = open(filesToUse[i]);
                 var fileName = docRef.name.split('.')[0];
                 var docSize = Math.max(docRef.width,docRef.height);
                 if(docRef.width>docRef.height){docRef.resizeImage(600, undefined, undefined)}
                 else{docRef.resizeImage(undefined, 600, undefined)};
                 docRef.saveAs (new File(saveFolder+'/' + fileName + '_1.jpg'), jpgOptions);
                 if(docRef.width>docRef.height){docRef.resizeImage(300, undefined, undefined)}
                 else{docRef.resizeImage(undefined, 300, undefined)};
                 docRef.saveAs (new File(saveFolder+'/' + fileName + '_2.psd'), psdOptions);
                 docRef.saveAs (new File(saveFolder+'/' + fileName + '_3.jpg'), jpgOptions);
                 docRef.close(SaveOptions.DONOTSAVECHANGES);
              catch(e){}
            };//end loop 2
    function IsFileOneOfThese( inFileName, inArrayOfFileExtensions ) {
        var lastDot = inFileName.toString().lastIndexOf( "." );
        if ( lastDot == -1 ) {
            return false;
        var strLength = inFileName.toString().length;
        var extension = inFileName.toString().substr( lastDot + 1, strLength - lastDot );
        extension = extension.toUpperCase();
        for (var i = 0; i < inArrayOfFileExtensions.length; i++ ) {
            if ( extension == inArrayOfFileExtensions[i] ) {
                return true;
        return false;
    // given a file name and a list of types
    // determine if this file is one of the provided types. Always returns false on platforms other than Mac.
    function IsFileOneOfTheseTypes( inFileName, inArrayOfFileTypes ) {
        if ( ! IsMacintoshOS() ) {
            return false;
        var file = new File (inFileName);
        for (var i = 0; i < inArrayOfFileTypes.length; i++ ) {
            if ( file.type == inArrayOfFileTypes[i] ) {
                return true;
        return false;
    function IsWindowsOS() {
        if ( $.os.search(/windows/i) != -1 ) {
            return true;
        } else {
            return false;
    function IsMacintoshOS() {
        if ( $.os.search(/macintosh/i) != -1 ) {
            return true;
        } else {
            return false;

  • Not able to add an excel file as data source to create new values in the mapped domain

    Hi
    I am trying to use some sample data from an Excel file to improve the quality of a Knowledge Base I have created in the Data Quality Client. I followed the following steps:
    Knowledge Discovery
    Data Source: Excel File
    Browsed to the Excel File on my local drive.
    I'm getting the following error: Failed reading Excel File
    I have checked the security settings, and provided full control to the user. I'm not sure as to what is the issue here. I
    am totally new in this field and with my little knowledge trying to build a Knowledge Base. But the hurdle stopped me.
    Thanks in Advance

    Hi
    You can add a  Excel file as the data source for a universe,  below are the steps.
    Ensure that the following steps are done before inserting a table from Excel sheet into a universe.
    1. Go to Excel and highlight all the cells that you want in the same table.
    2. Go to the Name box from Insert->Name->Define and give a name (in Designer, you see this name as a table of all the values you have selected).
    3. Go to Designer and pop up the table browser. You have to drag and drop the name you gave.
    and check the SP of ur BO.
    you can use .xls file as datasource but you cannot use .xlsx(windows 2007) .
    Regards,
    Rajesh

  • Cannot seem to write to iDisk to add a javascript file

    I am trying to add a javascript (js file) and a few png files into the folder of my iWeb site page on iDisk but it doesn't stay there. It appears to be copied but when I go back to check, it's not there. I have read and write permission to this unlocked folder. Although I have been using iWeb for awhile and have four working websites, I'm not real familiar with iDisk changes.
    By the way, is this the correct way to add a js file that is referenced by my HTML snippet?
    Help is much appreciated. Thx.
    Julie

    Sorry, but I'm still confused about syncing. Let me back up and find out if what I am trying to do is possible. I am using iWeb '08 version 2.0.3, by the way.
    I want to add an HTML snippet (Insert HTML Snippet) onto one of my website pages. The HTML snippet has a line referring to a script (<script type="text/javascript" src="sorttable/sortabletable.js"></script>). So I need to put the sortabletable.js script somewhere. It is in a folder called sorttable that also includes some png files as background images. I was thinking that I should put the sorttable folder into the folder on iDisk for that particular web page. So first of all, is this possible? Is it possible to add scripts to iDisk that are used in an HTML snippet on an iWeb page? The reason I'm asking is that I asked this question to Customer Support and they said: ..."iWeb does not offer the ability for the user to add custom HTML into the page."
    If this is possible, then I need to make sure I'm doing it right, which brings us to the syncing issue. My options for syncing (under System Preferences for .Mac) are for bookmarks, calendars, contacts, keychains, and mail-related things. I don't see an option to sync iWeb or websites or any other generic iDisk option. Could this be because I'm using Mac OS X version 10.4.11?
    Thanks again, in advance.

  • My itunes stops working when i try to add a music file to the library. how do i fix this?

    when I open iTunes and try to add a music file to my library from my computer, I slecet the song and click open and then it just comes up with the error message saying that iTunes has stopped woking and closes the program... ive tried everything- uninstalling and reinstalling the program and even disabling my antivirus software. I have no other ideas about how to fix this?

    If you are still having this problem, the fix below takes care of it.  It was posted in another conversation by Sony Singh. I did it, rebooted, and all works!!
    Copy QTMovieWin.dll from:  C:\Program Files (x86)\Common Files\Apple\Apple Application Support
    to: C:\Program Files (x86)\iTunes
    Hope this helps or you've already done the fix, especially since you posted in October.

  • HT4796 How can I take the files that were migrated from my PC to my Mac and add all those files to my current user instead of having 2 users?

    How can I take the files that were migrated from my PC to my Mac and add all those files to my current user instead of having 2 users? Having to log out just to sign in on a different user to access the files is absurd.
    Do I make all the files sharable to all the NOW users on the mac then just delete the files? Or can i erase my account that I made when starting up my new mac and then just use the one with the transferred files?
    I just dont want to have to og in and out of 2 different accounts .. Help please.         
    -Nina

    Sorry. /Users is a folder path. It would be similar to C:\Users (if that exists on Windows).
    So, in the Finder, select Computer from the Go menu.
    You'll see Macintosh HD, double-click that to open it.
    In there you'll see several folders. One is Users. That is where all the user Home folders exist. Select the other account's home folder and go to step 3.
    If you have any more confusion, please stop and ask. We'll get there.
    If you feel more comfortable, you can just log into that other account and move the files into /Users/Shared.
    Then, log into the account you wish to use and copy the files from the Shared folder and paste them into your Home folder, wherever they belong, Documents, Music, Pictures, etc.  That just takes a little more work. Transferring them into Shared, and then copying into your home sets the permissions on the files so that you won't have a problem accessing them later. The steps I provided just prevent you from having to do the double move, since you are not going to use the old account once you are done.
    Quick unix shorthand. If someone gives you a file path that begins with a /, that means the root of the hard drive, ie Macintosh HD (if you haven't renamed it). The path separator in unix is /, not \.
    A path that starts with ~/ means your Home folder, the one inside /Users named with your account name.

  • How do I add an existing file to a project?

    To add an existing files to a project in JDeveloper 9.0.5.2 I use File/Import and select "Existing Sources". In Jdeveloper 10.1.3.0.2 the "Existing Sources" option was substituted by "Create Project from Existing Source". The documentation topic in 10.1.3 “Adding Existing Files to an Existing Project Using the Add Files or Directories Dialog” indicates File/Open and use a “Add Files or Directories dialog” that I can not find.
    How do I add an existing file to a project?

    To add an existing files to a project in JDeveloper
    9.0.5.2 I use File/Import and select "Existing
    Sources". In Jdeveloper 10.1.3.0.2 the "Existing
    Sources" option was substituted by "Create Project
    from Existing Source". The documentation topic in
    10.1.3 “Adding Existing Files to an Existing
    Project Using the Add Files or Directories Dialog”
    indicates File/Open and use a “Add Files or
    Directories dialog” that I can not find.
    How do I add an existing file to a project?Right now you just need to copy the file into the sourcepath of your project, going forward we're going to provide some easier way to do this.
    i.e. you can use the windows explorer to copy C:\src\com\acme\MyClass.java to C:\jdev\mywork\Application1\Project1\src\com\acme\MyClass.java
    Hope this helps,
    Rob
    Team JDev

  • How do I add a log file to posts? (NT)

    How do I add a log file to posts?
    Thanks,

    here is the output of copy/paste:
    I [17/Oct/2007:05:51:44 -0500] Configured for up to 100 clients.
    I [17/Oct/2007:05:51:44 -0500] Allowing up to 100 client connections per host.
    I [17/Oct/2007:05:51:44 -0500] Using policy "default" as the default!
    I [17/Oct/2007:05:51:44 -0500] Full reload is required.
    I [17/Oct/2007:05:51:45 -0500] Loaded MIME database from '/etc/cups': 35 types, 40 filters...
    I [17/Oct/2007:05:51:46 -0500] Loading job cache file "/var/cache/cups/job.cache"...
    I [17/Oct/2007:05:51:46 -0500] Full reload complete.
    I [17/Oct/2007:05:51:46 -0500] Listening to :::631 on fd 2...
    I [17/Oct/2007:05:51:46 -0500] Listening to 0.0.0.0:631 on fd 3...
    I [17/Oct/2007:05:51:46 -0500] Listening to /var/run/cups/cups.sock on fd 4...
    (The strikethrough is one of the many bugs in the Forum software...)
    Use Console Utility to show you the log files, if that is what you need to know.

  • How do I add a txt file to read from in the following script

    First thanks for the help, PS newbie. 
    I need to add a txt file that has the Exchange aliases listed to the below file. So if the .txt file is sitting in c:\temp\readme.txt how do I incorporate into the following script. Given, I only want the outcome to read from only the txt file. 
    $mailboxes = Get-Mailbox -RecipientTypeDetails UserMailbox
    ForEach ($mailbox in $mailboxes) {
      $FilePath = "\\server\folder\" + $mailbox.PrimarySmtpAddress.Local + "@" + $mailbox.PrimarySmtpAddress.Domain + ".pst"
      New-MailboxExportRequest -mailbox $mailbox -FilePath $FilePath
    Thank you for your time. 
    Chris

    Thank you - 
    You're welcome.
    I need to make sure that when the user from the list is exported to .pst it is named with their primary smtp address? Will the above code do so?
    No, it won't. This adjustment will take that into account:
    $aliasList = Get-Content .\aliasList.txt
    foreach ($alias in $aliasList) {
    $mbx = Get-Mailbox $alias
    $filePath = "\\server\folder\$($mbx.PrimarySmtpAddress).pst"
    New-MailboxExportRequest -Mailbox $alias -FilePath $filePath -WhatIf
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

  • How can I add an AVI file to iMovie?

    I have iMovie '11. It won't let me add a .AVI file. If I can't add a .AVI file what is the best FREE software to convert it and what should I convert it to? Thanks!

    I agree with the Streamclip suggestion for two reasons.
    The first is that it is free and works well.
    The second is that Streamclip is so essential that if one doesn't have it on one's computer, one is missing a very fascinating piece of software. Free, converts faster than anything Apple uses, and gives you a little window to see the conversion to make sure everything is going ok.
    Hugh

  • How can I add an audio file to each slide when I export to HTML Keynote 6.2

    How can I add an audio file to each slide when I export to HTML Keynote 6.2
    I am trying to create an audio slide show instead of a movie

    Drag and drop one music files onto each slide then export. (File > Export > HTML)

  • How can I add an audio file to a .mov video?

    Im trying to add an audio file (format 'aiff'), to a video in the format of .mov
    I can't find anything that will just let me combine the two files to make one .mov video file.
    Any suggestions?
    Cheers!

    Drag and drop one music files onto each slide then export. (File > Export > HTML)

  • How to add an audio file to a link

    I am working on a project using IWeb and I am trying to figure out if it is possible and then, if it is how to add an audio file to a link. I would really be glad of your help as I am having problems meeting the requirements of the project if I don't make it work.
    Also, is it possible when having added a movie clip from quick time player to have the clip start as soon as the page is "opening", that is without pressing the play button?
    I am waiting in great suspense to see if anybody can help me out. If you have the answers to my questions, please send me an email at [email protected] - thank you so much :o)

    Hi Maiken
    Welcome to the discussion forums.
    All you need is open iWeb, select text or image, open inspector, go to link, check the "enable as a hyperlink" box, in "link to" there's a teardown menu where you select "a file" and select the file you want to link to.
    If you want to have it downloading look at [this|http://alyeska.altervista.org/en/iWeb_Downloads.html]
    For the second question:
    select the movie file in iWeb go to inspector, then to the last icon (showing the quicktime logo) and check the box that say "Autoplay".
    Regards,
    Cédric

  • How to add a Java file from ejbModule to EJBCandidates ?

    Hi,
    In my java client proxy project, I have got the EJBCandidates generated. But I need to add one more java source file from ejbModule to EJBCandidates.
    If I right click on the java file I need to add, am not getting that option for adding.
    <b>Please help me how to add java source file from ejbModule to the EJBCandidates.</b>
    Thank you.

    Great... :-)
    Thank you very very much xHacker :-)
    That what just what I needed.

  • How to add the property file..ie(default.properties) to a webdynpro project

    Hi All,
    How to add the property file..ie(default.properties) to a webdynpro project.
    I urgently require the solution. Kindly get it for me.
    Regards
    DK

    Hi DK,
    this is described in the second Web Dynpro Java Tutorial
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/downloaditem?rid=/library/uuid/b1a3e990-0201-0010-aeb2-a2ef5bc3da8e">creating an Extended Web Dynpro Application</a>
    Regards, Bertram

Maybe you are looking for

  • Identity Services Engine Initialization Error

    I have been working with TAC and other's at Cisco to resolve this problem, and also have a case open with the developers. However, I thought it might be a good idea to open it up to you all to see if you had encountered this problem in the past. I am

  • "Cannot place this file.  No filter found for requested operation"

    Hello, Saw earlier postings on this but not quite the same situation and/or the solutions didn't work.  Using InDesign CS 6.  Trying to place many JPEG files.  First one placed.  After that, stopped working.  Trying closing out of InDesign and restar

  • Content Aware Fill in Photoshop CS5.5 has quit working

    Content Aware Fill in Photoshop CS5.5 has quit. Was working just fine now nothing happens.

  • OS X Lion update help

    i just got a macbook(black version) and it came with OS X Snow Leopard. i was wondering where i can get the OS X Lion update since mountain lion is not compatible with my computer. Can someone help please.

  • Help needed on DATABASE ERROR: : unable to initialize mutex

    Hello, I am trying to run Berkeley DB on a MIPS platform using DbEnv. While the code runs fine on Linux RedHat, it throws the following error message when run on the MIPS: DATABASE ERROR: : unable to initialize mutex: Function not implemented DATABAS