Add File Name as Text Layer

Adobe Photoshop

If you’ve ever needed to add a text layer that contains the name of the open file here is a script to make it happen.

Download the script:  AddFileName20pt.jsx and double click to unzip the file.

Quit Photoshop.

Place the script in your Photoshop CS5/Presets/Scripts folder.

Launch Photoshop.

Open your image.

Select File > Scripts > AddFileName20pt

A word of caution, it is doubtful that the script will add the type layer at the exact size and in the exact position that you will want it. In order to make changes to the type style (size, font, color etc.), it is CRITICAL (especially if you are recording the script as part of an action) that you double click on the “Filename” type layer in the Layers palette and make changes to the type (font, size etc.) using the Options bar. Do NOT swipe the text in the image area or it will record that file’s name as part of the action and all of the following images will be named the same as the first one that you recorded!

Special thanks to Thomas Ruark at Adobe for creating this script.

Adobe Photoshop

Posted on 09-20-2010


  • By Laser - 3:14 PM on September 27, 2010  

    Where can I find the script to download?

  • By Julieanne Kost - 3:52 PM on September 27, 2010  

    Sorry, I just updated the post and added a link to download the script.

  • By ina - 11:48 PM on December 26, 2010  

    This script does not seem to work with Photoshop CS5… either that or it’s impossible to set the activeDocument to the currently open one

  • By Julieanne Kost - 1:58 PM on January 4, 2011  

    I just tested it again and it works for me if I follow the steps above. Are you on Mac or Windows? (Note the type layer will be named “Filename” but the actual name of the file will appear in the image area.)

  • By Ben Elliott - 9:40 AM on November 8, 2011  

    Can you give any indication how to automate the position of the inserted file name text layer?

    • By Julieanne Kost - 9:35 AM on November 11, 2011  

      When you are recording the action, you can use the Move tool or Free Transform to reposition the type. You can also use any of the options in the Options bar to make changes to the type such as change the font or size – but if you make changes to the Type tool’s options, you need to remember to only select the Type layer and make changes, don’t select the individual characters of the type.

      • By Ben Elliott - 12:07 AM on November 12, 2011  

        Many thanks. I’m still coming to grips with “actions”

  • By Vincent MacNamara - 4:52 AM on March 15, 2012  

    I’m experiencing a problem trying to incorporate this into an action. I double click the text layer to change the font size and colour in the options bar, but I’m getting the filename of the image used to create the action every time I do this. I can move the layer ok without it changing, but one I attempt to edit the font it changes. Am I missing something, or is it possible to edit the script to use the font, colour and position I want?

    • By Julieanne Kost - 10:17 AM on March 15, 2012  

      Dont double click the text layer. Just click the text layer to select it, select the type tool and change the font etc in the options bar.

  • By Marilyn - 8:01 AM on March 26, 2012  

    I want to batch a bunch of files using the script so I recorded an action to change the font, size, postion, etc. however when I run the batch, it puts the same file name that I used to create the action on all of my files. How can I get it to add the correct filename?

    • By Julieanne Kost - 6:16 PM on March 27, 2012  

      You can make any changes to the text if you select the type tool and make the changes in the Options bar. If you select the type in the image area using the text tool, then you will only get the first name that you changed when recording the script.

      • By Marilyn - 8:03 AM on March 29, 2012  

        YESSSSSSSSSS! It worked this time. I was highlighting the text and changing it in the options bar instead of leaving the text unhighlighted. This is going to save me alot of time and headaches. Thank you a bunch!!!

  • By chloe - 12:19 PM on April 25, 2012  

    thank you so much for these instructions & script! It took me a bit of time to figure out NOT to double-click the type layer, but I finally got my action to work. I love love love batches and watching my computer work for me while I sit back and relax 😉

  • By Brian - 1:31 PM on August 13, 2012  

    Any suggestion for special characters like dashes?

  • By Ekaterina - 2:15 AM on September 4, 2012  

    Is there any script that would add text layers with PS layers titles?

  • By Mike Santistevan - 6:24 PM on December 18, 2012  

    Julianne, once more your in-depth knowledge of this tool has saved me hours of manual work not to mention made it impossible for me to enter a typo. And thanks to Thomas for writing such a handy script!!

  • By James Pyle - 11:09 PM on May 15, 2013  

    I was very exited to find this because it was going to save me much time, the issue is every time it adds the text it is random sizes in each all my images end up with different results after running a batch.

    • By Julieanne Kost - 8:40 AM on May 16, 2013  

      Are you sure that it’s the text size that is changing? I have a feeling that the images that you are running the script on are different sizes.

  • By Ian Harker - 7:33 AM on June 14, 2013  

    I’ve got everything doing what i need it to do in my action except the positioning. Because the text layer comes in dead center it always moves the text the same distance from the center regardless of the size of the document. I need the text to end up in the top left corner (X:0 / Y:0) regardless of the document size. Right now on larger documents it’s not making it all the way to the top left. It doesn’t seem to record when i change the reference point and enter 0 & 0 into my X/Y coordinates, it just moves it the same distance as it travels in the original file i programmed the action.

    Is there another way I should be moving the text layer to get the necessary effect, or is there a way to edit the script itself to alter where the text initially appears?

    • By Julieanne Kost - 1:26 PM on June 19, 2013  

      Can you try setting your preferences for Units to Percentage and then record the action to reposition?

  • By David - 2:45 AM on June 28, 2013  

    Thank you for this script! This will save me lots of time and ££££. THANK YOU.

  • By Patrick - 3:54 PM on August 13, 2013  

    Just wanted to say thanks in a big way for your script on including the file name in the image. I am using CS4 and your directions worked a treat and saved me heaps of time. Greratly appreciated.