9 Replies Latest reply on Feb 2, 2017 10:59 AM by spaciousmind

    using regular expressions to remove part of a text stream

    spaciousmind Level 1

      I've got a script to take a psd file, convert to CMYK, flatten it and save it out with "CMYK_flat.psd" on the end of the new file.

       

      All of that works fine, but I often work on RGB files and sometimes name them with _RGB.psd so I can see everything at a glance.
      I need to use expressions somehow to search for the exact phrase of *RGB* anywhere in the name and remove it.
      so I dont end up with names like this: myfile_RGB_CMYK.psd

       

      here are the relevant lines of codes that I'm using to get the document name and save it out, if it helps:

      var docName = app.activeDocument.name.match(/(.*)(\.[^\.]+)/)[1];

      and

      var saveFile = File( CurrentPath + "/" + docName + "_CMYK_flat.psd");

       

      I've tried a few things but don't really have a clue how to do this, so any help would be appreciated.

       

      Thanks!