Photoshop Script add name of Image file as text, but remove '-' character

I found a script that will take the name of my image file and place it on the image, less file extension. I added this to an action, which works exactly how I want, but my filenames have '-' characters in them.

Is it possible to remove the '-' characters of the script? I was not able to get the function replace to work. (that I need).

This is the code that works right now:

// Now create a text layer at the front
  
var myLayerRef = docRef.artLayers.add();
  myLayerRef
.kind = LayerKind.TEXT;
  myLayerRef
.name = "Filename";

  
var myTextRef = myLayerRef.textItem;

  
// strip the extension off
  
var fileNameNoExtension = docRef.name;
  fileNameNoExtension
= fileNameNoExtension.split( "." );
  
if ( fileNameNoExtension.length > 1 ) {
  fileNameNoExtension
.length--;
  
}
  fileNameNoExtension
= fileNameNoExtension.join(".");  
  myTextRef
.contents = fileNameNoExtension.substring(2);


  
// myTextRef.contents = fileNameNoExtension.replace(/^-/i, '');


  
// off set the text to be in the middle
  myTextRef
.position = new Array( docRef.width / 2, docRef.height / 2 );
  myTextRef
.size = 28;
}

myTextRef.contents = fileNameNoExtension.replace (/-/ g, ");

Tags: Photoshop

Similar Questions

  • Open a new file in photoshopcc and the name of the file is displayed but no Web white work. You can see it as a layer in the layers panel and if I pull on the grey area I see int on the layer, but not on the main screen.

    Open a new file in photoshop cc and the name of the file is displayed but no Web white work. You can see it as a layer in the layers panel and if I pull on the grey area I see int on the layer, but not on the main screen.

    Nice day!

    Could you please post a screenshot with the relevant panels visible?

    Not turning off"use graphics processor" in the Performance preference and restarting Photoshop have a bearing on the issue.

    Kind regards

    Pfaffenbichler

  • The name of the file as IPTC, but without the extension. (Currently using script of dam)

    Hello

    My apologies if this isn't the right forum to ask this question:

    I am currently using the name of the script file of title with CS4 Bridge - DAM http://www.damuseful.com/pages/PimpMyBridge.html - to get the name of the file in the IPTC title script. This however in the extension in the title field also puts. A JPG file named 2000 ends with 2000.JPG upward in the title field. I would like to not have the extension appear in the title field.

    Is it possible by modifying the script DAM / using any other script available for free.

    In case it helps, that's what the dam script currently looks:

    #target bridge

    If (BridgeTalk.appName = 'bridge')

    //-----------------------------------------------------------------------

    This script copies the file names of the thumbnails selected in the title field

    Also shows how to add menu items

    AdobeLibrary scripts should be loaded

    This script was created by John Beardsworth www.beardsworth.co.uk/ and modified by Peter Krogh www.DAMuseful.com

    This script can be freely distributed and modified

    //--------------------------------------------------------------------

    We will create our menu

    var menu = MenuElement.create ("command", "write to IPTC title field Filename', 'at the end of the tools');

    menu.onSelect = function (m)

    {

    var getFolderChildren = true;

    var filesOnly = true;

    var inches = getBridgeThumbnails (TYPES. PHOTOSHOP_OPENABLE, getFolderChildren, filesOnly);

    for (var i = 0; i < thumbs.length; i ++)

    {inch = inches [i];}

    MD = thumb.synchronousMetadata;

    ' md.namespace = ' http://ns.Adobe.com/Photoshop/1.0/ ";

    MD. title = thumb.name;

    }

    Window.Alert ("Done" + i + "records");

    };

    There are also 3 other Adobe library scripts that come with the download.

    I don't know anything about scripting, baby-steps would be appreciated.

    Thank you very much.

    Change:

    md.Title = thumb.name;
    

    TO:

    md.Title = decodeURI(thumb.name).replace(/\.[^\.]+$/, '');
    
  • How can I bulk add name of photo file

    I would like to add the name of the image file, so that when people look at the name of the file image is embedded in the image.

    I did some research on this top and have found some mention of the tools that people build to do this and indeed a lot of different things I guess.

    I'm using 10 PSE. Windows 7 Prof  As I understand it, I can't build tools because my version for example of items is not full blown. But if people have to build something for it I can then add it to my software and it works for me.

    Although full, quick or even guided, it seems to be an option under file/automation tools. This seems to be what I need.

    Can anyone tell me where this add on is and how to use, I can't find it and I don't really know if it will work with 10 of PSE. Many References I've seen seem to be for the previous version.

    There may be a simpler way?

    Thank you

    I'm not sure why process several files > legends > file name does not work? Sorry if I'm missing something here:

  • Assign names of image files

    Hello

    I acquire images every few nanoseconds from a camera through LabVIEW.

    What is the best way to make the device wait 10 nanoseconds, and then align an image using IMAQ (I already have the image snapping VI) and then download this image in BMP format with a certain file name (for example pic1.bmp) in a given folder?

    I don't want the camera to have to wait for the computer to download the image, because that may cause a delay.  Any help?

    I was thinking something like in a loop for, I've got the snap and wait for the screws, and goes from the image acquired in an array, which is then saved after all the images are broken.  But how would name each image in the table the name of the file I want?


  • RH8 - the names of Image files

    Greetings,

    In a generated project, created in the RH8, when the user hovers over an image, name of file screens. I checked the properties of the image and screen Tip text field is empty.

    How can I prevent the name of the image file to display in the generated project?

    Thank you

    Hello

    When you look at the generated code, what do you see? Is there a Title attribute or an Alt attribute? You didn't say what was the output type. What WebHelp? If so, have you turned on Section 508 options when you generated? (Part of being compatible with Section 508 is to give images corresponding names)

    See you soon... Rick

    Useful and practical links

    Wish to RoboHelp form/Bug report form

    Begin to learn RoboHelp HTML 7 or 8 days - $24.95!

    Adobe Certified RoboHelp HTML Training

    SorcerStone blog

    RoboHelp EBooks

  • Need help! -Photoshop - can't change the size of the text in the character Panel

    Then all of a sudden, I am unable to change the size of the text in the character Panel. I select the text in my document, then go in the character Panel and type in let say "55"... but is not type it in Control Panel... it Pat on the current document in the selected type - like ill have a selected phrase and then it will be replaced by 55... It also happens in the areas of kerning value and leader of the group - does anyone know what is happening? Ive handed in market and update photoshop... maybe I hit something that blocks? I've never known my life of complete photoshop user

    I'm on CC 2015.1.2

    But I think that his work now... I just is gone in the Charter Panel and clicked on the 'fractional' in and out 'reset the character' and now it seems to work normally... how strange

  • Installation of Photoshop has caused all the image files Hang PC when clicked

    I installed Photoshop on my PC of 10 windows recently. It works fine, but now when I right click on any photo on my PC (to get the properties, for example), hangs it PC for more than 30 seconds, which doesn't look much, but believe me, it is maddening if you do this a lot.

    I went in the settings to "Default programs" of Windows and made sure Photoshop is not the default for .jpg and .png files. Which made no difference. I have no idea what else to try, short of uninstalling Photoshop.

    Thanks in advance for any advice on this.

    One note, under windows, it is also tasks and services. These are modified in the computer management console.

  • Data merge InDesign, the names of image files

    I have a directory of more than 300 people with photos. I do a fusion of data from an Excel worksheet. Is it possible to automate the path names in the spreadhseet for each person, or do I have to type each file name for each picture? All the pictures are in the same folder.

    For example:

    @Photo

    Accounts: Photos: directory: Doe, John

    Thank you

    Lisa

    So just do your column has this formula, for example enter A2 and copy it down.

    = "" pr:PHOTOS:Physician photos repertoire: "UPPER (B2) &", "& LOWER (C2) &".psd""

    And then you are ready!

  • The system creates thousands of useless with names like temporary files ~ WRL2755.tmp, but they never disappear. How can I remove all at the same time?

    I am running XP Professional 2002 SP3. It all started about six months ago I suspect with one of these updates. These files are located in the files with the associated files. There are actually hundreds of thousands of them. They have tripled the number of files on my computer. I want to know how to get rid of them and stop the system from their creation.

    Hello Redoced,

    I found an article from knowledge explaining that ~ WRL .tmp files are created by Word, further than the WRL type .tmp files are created by Clipboard actions.

    Description of how Word creates temporary files

    Because the problem you posted is related to the word and it would be better suited to the community of Office Discussion groups. Please visit the link below to find a community that will provide the support you want.

    Office Word newsgroup

    Steven
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think

  • Name of the file list email - LR4?

    I am doing a long list of names of image files (selected images in the library) then copy and email in LR4.

    Can someone tell me if this is possible and how I could do it, please?

    Thanks for your suggestions,

    Stephen

    http://lightroomsolutions.com/a-quick-list-of-filenames/ contains the file.

    The Scripts folder must be in the same folder in Lightroom that those such as models of the Smart Collection, predefined text Style.

    On Mac, you see a funny mark to the right of help.

    John

  • Microsoft Digital Imaging Anniversary Edition-could not remove photos from the digital image library

    Microsoft Digital Imaging Anniversary Edition

    I have problems with digital imaging.  Never been wrong before, so I'm puzzled!  Recently added pix from CD to digital photo Image file picked up but did not display the photos on the page of digital image library - they come just under the icon standard w/o a view of the pix.  I tried to delete these files where the pix would not come to the top of the digital image.  Digital image would not remove them.  I deleted the pix of the computer files.  Digital image still would not remove the files in the library. I went into the Control Panel, I removed & reinstalled the Digital Image, but all files keep coming back.  Digital Imaging tells me I have 4000 photos stored there!  If I do, where are they?  I can't find them!   Is there something else I can do?

    I use Windows XP.  I've seen Info for Vista, but I need it for XP.

    I have problems with digital imaging.  Never been wrong before, so I'm puzzled!  Recently added pix from CD to digital photo Image file picked up but did not display the photos on the page of digital image library - they come just under the icon standard w/o a view of the pix.  I tried to delete these files where the pix would not come to the top of the digital image.  Digital image would not remove them.  I deleted the pix of the computer files.  Digital image still would not remove the files in the library. I went into the Control Panel, I removed & reinstalled the Digital Image, but all files keep coming back.  Digital Imaging tells me I have 4000 photos stored there!  If I do, where are they?  I can't find them!   Is there something else I can do?

    I use Windows XP.  I've seen Info for Vista, but I need it for XP.

    ========================================
    The MS Digital Image Library maintains a proprietary database
    named Pictures.pd3 who is not deleted when the program is
    uninstalled/reinstalled.

    If you rename Pictures.pd3 to Pictures.OLD... the next time you
    Open the library, it will be because it was the first opening.

    Windows XP... the Pictures.pd3 database file is located at:

    C:\Documents and Settings\.
    Local Settings\Application Data\Microsoft\
    POD\Pictures.Pd3

    If you can't find the file, open a file and
    Reach... Tools / Folder Options / View tab on...
    Tick... Display the hidden files and folders / apply / OK.

    Volunteer - MS - MVP - Digital Media Experience J - Notice_This is not tech support_I'm volunteer - Solutions that work for me may not work for you - * proceed at your own risk *.

  • I downloaded a file of visualization for Windows Media Player from Microsoft. The downloaded file is there, but I can't seem to read in the media player. How to play?

    the file is: next-generation visualizations. The Publisher is Microsoft. Advanced 3D Hardware. Version 1.0.0 of download:PsychedeliaVizPak.msi product name

    Type: Windows Installer 5.53 MB Package of: download.microsoft.com

    I have Service Pack 2 32-bit

    When I go to the media player and use the bars drop to visualizations names of downloaded files are there, but when I click on it the screen remains empty. I downloaded other visualizations and they work fine.

    Hello

    .msi is simply microsoft program so if you have windows, means that you can run it... ;) I had the same problem too, but it turns out that it was caused by my graphics driver... I have nvidia and its recent update supported not only such things... I had to reinstall the whole system and now it works again (that I na not reinstall just cos of visualizations) but try to reinstall your graphics card driver... hope that helps... :-) or you can even try the opposite... uninstall the current driver and run the older again, might help, but will prevent probably other programs functions...:-/ then make the choice... :) but I can confirm that psychedelia skins are pretty cool... ;)

  • Script to add keywords in Bridge based on the name of the file

    I'm working on a script that adds keywords based on the name of the image file. So, if the name of the file is AG123456 (08_16) .tif, this script would add "Agriculture", "123456" and "8/16" as keywords in bridge. "" I have a small sample of the part that retrieves the name of the file written in AppleScript below of each keyword. I know that I need to write the part that actually adds the keywords in Bridge in JavaScript, because the bridge is not capable of AppleScript. I have trouble finding the JavaScript code, I need to add the keyword. If someone could help me with this, I would really appreciate it.

    I would like to call the JavaScript code to in AppleScript instead of writing all the code in JavaScript. (The full version of it's longer, it would be a lot of code to change in JavaScript).

    on Open of droppedfiles

    with timeout of 900 seconds -> Changing timeout to 15 minutes. Default value is 2 minutes.

      -------------------------------------------------------------

    -GET THE CHARACTERS OF THE FILE name

      -------------------------------------------------------------

    Repeat with aFile in droppedfiles

    say application 'Finder '.

    the value file name to name of aFile

    end say

      -------------------------------------------------------------

      -------------------------------------------------------------

      -------------------------------------------------------------

    -ADDED a KEYWORD FOR EACH PREFIX

      -------------------------------------------------------------

    -Find the prefix in the name of the file

    if text 1 thru 2 of file name contains "AG" then

    the value prefixKeyword to 'Agriculture '.

    else if text 1 thru 2 of file name contains "To THE" then

    the value prefixKeyword to "Automobile".

    on the other

    the value prefixKeyword to "Need to prefix".

    end if

    -Adding the prefix as a keyword

    display dialog prefixKeyword string

      -------------------------------------------------------------

      -------------------------------------------------------------

      -------------------------------------------------------------

    -ADDED a KEYWORD FOR EACH SKU NUMBER

      -------------------------------------------------------------

    -Creating a list of all single digit numbers

    the value numberList to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}

    -Looking FOR THE SKU NUMBER

    -Looking for a six-digit number that starts on the third character of the file name

    if numberList contains (text 3 of file name) et numberList contains (text 4 of the file name) et numberList contains (text 5 of filename) et numberList contains (text 6 of file name) et numberList contains (text 7 of file name) then

    if numberList does not work contain the text 9 of file name and then

    if numberList contains (text 8 of the file name) then

    the value skuNumber to of 3 to 8 text filename

    the value skuNumberOffset to 8

    end if

    end if

    -Searching for a six-digit number that begins on the fourth character of the file name

    else if numberList contains (text 4 of the file name) et numberList contains (text 5 of filename) et numberList contains (text 6 of file name) et numberList contains (text 7 of file name) et numberList contains (text 8 of the file name) then

    if numberList does not work contain the 10 text of file name and then

    if numberList contains (text 9 of file name) then

    the value skuNumber to text 4 to 9 of file name

    the value skuNumberOffset to 9

    end if

    end if

    -Defining the SKU number to alert keyword keyword the user can search the

    on the other

    the value skuNumber to "Need SKU number.

    set skuNumberOffset to 0

    end if

    -ADDING THE SKU AS NUMBER one keyword

    display dialog skuNumber string

      -------------------------------------------------------------

      -------------------------------------------------------------

      -------------------------------------------------------------

    -DATE ADDITION OF FILE name

      -------------------------------------------------------------

    if file name contains "(" et nom de fichier contient ")" then "

    set leftParen to "("

    set rightParen to ")"

    -Obtain the month of the file name

    set monthOffset of (offset of leftParen in fileName) + 1 -> character returns immediately after)

    set fileNameMonth to character of filename monthOffset

    -Get all the numbers of the year of the file name

    set fileNameYearOffset1 to (offset of leftParen in file name) + 3

    set fileNameYearOffset2 to (offset of rightParen in file name)-1

    set fileNameYear1 to character of filename fileNameYearOffset1

    set fileNameYear2 to character of filename fileNameYearOffset2

    set of characters fileNameYear fileNameYearOffset1 to fileNameYearOffset2 of file name

    set dateKeyword to fileNameMonth & "/" & fileNameYear

    -ADDING THE SKU AS NUMBER one keyword

    display dialog dateKeyword string

    end if

      -------------------------------------------------------------

      -------------------------------------------------------------

    fin Repeat

    end timeout

    end open

    Here's an example of adding of keywords in a file, the code can be used in Bridge or Photoshop.

    var Keys = ["keyword1","keyword2","keyword3"];
    var file = File (Folder.desktop + "/zz.jpg");
    if(file.exists) setKeyword( file,Keys);
    
    function setKeyword( file,Keys){
    if ( !ExternalObject.AdobeXMPScript ) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
            var xmpf = new XMPFile( File(file).fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE );
            var xmp = xmpf.getXMP();
            for(var s in Keys){
            xmp.appendArrayItem(XMPConst.NS_DC, "subject", Keys[s], 0,XMPConst.PROP_IS_ARRAY);
        }
          if (xmpf.canPutXMP( xmp )) {
             xmpf.putXMP( xmp );
          }
          xmpf.closeFile( XMPConst.CLOSE_UPDATE_SAFELY );
    };
    
  • Add the name of the file description

    Hello

    We have a droplet images opening, change their color profiles, flaterning, etc one by one.

    This droplet, mainly with a signle script, is finally going to also change the names of files.

    I want to retain the file name of each picture in his "description of metadata.

    I saw it was douable in Bridge as shown below, can even be done in Photoshop cs6?

    1. #target bridge
    2. If (BridgeTalk.appName == 'bridge') {}
    3. FT = MenuElement.create ("command", "Add to Description file name", "at the end of the tools");
    4. }
    5. FT.onSelect = function () {}
    6. var = app.document.selections inches;
    7. if(!thumbs.) Length) return;
    8. If (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
    9. for (var a helping hand in) {}
    10. var selectedFile = .spec inches [a];
    11. var FileName = replace decodeURI (selectedFile.name) (/ \.) [ ^\.] +$/, '')
    12. var myXmpFile = new XMPFile (selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
    13. var myXmp = myXmpFile.getXMP ();
    14. var / / Desc = [];
    15. var count = myXmp.countArrayItems (XMPConst.NS_DC, "description");
    16. for (var i = 1; i < = count; i ++) {}
    17. DESC.push (myXmp.getArrayItem (XMPConst.NS_DC, "description", i));
    18. }
    19. DESC = DESC. ToString() + "" + file name;
    20. myXmp.deleteProperty (XMPConst.NS_DC, "description");
    21. myXmp.appendArrayItem (XMPConst.NS_DC, "description", Desc, 0, XMPConst.ALIAS_TO_ALT_TEXT);
    22. myXmp.setQualifier (XMPConst.NS_DC, 'description [1]', 'http://www.w3.org/XML/1998/namespace"," lang"," x - default "" "); 
    ! important; background-color: inherit; "> If (myXmpFile.canPutXMP (myXmp)) {}
  • myXmpFile.putXMP (myXmp);
  • myXmpFile.closeFile (XMPConst.CLOSE_UPDATE_SAFELY);
  • }
  • }
  • }
  • If you want to save the name of the file in the description field, just use in Photoshop:

    var doc = activeDocument;
    doc.info.caption = doc.name
    

Maybe you are looking for

  • iPod classic 160 GB says no music after synchronization

    I have an old iPod classic 160 GB that has worked well for years. But suddenly, last week, while he was trying to put in new music (right now I have about 18 000 songs, more or less) he began to have problems with synchronization. After having tried

  • Satellite A100-447 - DVD player does not read some discs

    Hello I have a 4 month old Satellite 100-447 (PSAAN), came preloaded with Vista Home Premium and a carpet * CD/DVD super-multi UJ-850 s player. The DVD player does not work properly. It will recognize a few blank, but never DVD-R DVD and won't recogn

  • down the mode full-screen!

    Can you tell me how to get the screen out of fashion full screen? Thank you

  • Published java app but APN issues dragging customers down

    Hello, we recently published our app, fuel UK which was quite popular in its early days, but is being hampered by the 'Tunnel failure' / AFN misconfuguration questions on client machines. All that we can do to make the application more reliable when

  • Restoring an incremental backup Windows 7

    This may seem a stupid question, but it's confusing in the interface.  I want to restore my backup files of the Windows (from the control panel).  There are two dates when I did a backup of Windows.  When I go through the Restore Wizard, he mentions