Rename Layers: Find and Replace style renaming

In Illustrator, you can use the following to find and replace layer names:
var doc = app.activeDocument; 
// name indexed object 
var layernames = { 
'Bob':'Bob Front'
// loop through all layers 
for (var i = 0; i < doc.layers.length; i++) 
//Set up Variable to access layer name 
var currentLayer = app.activeDocument.layers[i]; 
if (layernames[currentLayer.name]) 
  currentLayer.name = layernames[currentLayer.name]; 
In this script "Bob" will become "Bob Front". Is there something similar for Photoshop. Looking at the Photoshop scripting guide, this script should work as the active App document and layers methods exist in Photoshop.

c.pfaffenbichler wrote:
What are
var layernames = {
'Bob':'Bob Front'
and
if (layernames[currentLayer.name])
supposed to do? Is that even JavaScript? …
Hi c.pfaffenbichler, yes, this is pure Javascript.
Try this little example:
var layernames = {'Bob':'Bob Behind'};
alert(layernames['Bob']);
// a variant
layernames['Bob'] = 'Bob in the middle';
alert("a variant:  " + layernames['Bob']);
// another variant
layernames.Bob = 'Bob Front';
alert("another variant:  " + layernames.Bob);
@big_smile,
your posted script works with photoshop (if you have only artlayers and one or more layers named with Bob)
var doc = app.activeDocument;
// name indexed object
var layernames = {'Bob':'Bob Front'};
// loop through all layers
for (var i = 0; i < doc.layers.length; i++) {
    //Set up Variable to access layer name
    var currentLayer = app.activeDocument.layers[i];
    if (layernames[currentLayer.name]) {
        currentLayer.name = layernames[currentLayer.name];
All you have to do is to loop trough all artlayers (and layersets), but here is Javascript a slowly variant. Use ActionManager code instead. You will find many examples here in forum.
Have fun

Similar Messages

  • Find and replace by text and style

    We have a fairly large RH HTML project (300+ topics so far)
    most of which have a specific heading in Heading2 style. We want to
    change all of these to a style based on Heading2, but not use the
    Heading2 style b/c we don't want them to show up in the TOC. I have
    created a new style and can obviously open every topic and manually
    select and change each one - but I'm hoping that one of your RH
    gurus will tell me an easier way. Is there anything comparable to
    MS Words Find/Replace that will search the whole project for a
    specific word in a specific style?

    RoboHelp's Multi-File Find and Replace (in the Tools tab)
    should be suitable for this job, and you can control each
    occurrence as you choose. (Where this RH utility fails is when your
    search string might sit on more than one line, which won't be the
    case here.)
    You'll run two replacement passes (spaces added to < &
    > tags for proper viewing in this forum):
    Replace < h2 > with < p class=YourNewStyle >
    Replace < /h2 > with < /p >
    The < h2 > and < /h2 > strings will never be
    split between lines, so RH will catch every one.
    BTW, Add me to the list of FAR boosters; it'll let you change
    case, change file names, etc., etc., etc. Great tool!
    Good luck,
    Leon

  • Find and replace a table style

    I have about 10  table styles in a document and I want to replace all of them with the #1 table style. Can this be done with Find and Replace?

    You'll need to do this for each of the Table formats that need to be replaced.
    Let's assume the desired format is "Format A" (a default FM style), and one of the formats to be changed is "Specs 2".
    Click in any instance of a Specs 2 table.
    In the Table Tag field, pull down and click on [Format A].
    Click Commands > Global Update Options:
    (*) All Properties
    (*) All Tagged [Specs 2]
    [Update]
    If it works properly, you'll get a dialog:
    OK to change all Format B tags to Format A?
    [OK]
    Additional global updates may be required to clean up any overrides.
    Trying this on FM7 at home, it didn't always work. I don't know if newer versions are more stable. Personally, I never do it this way (probably because of prior experience), and I usually just hack the MIF.

  • Do there is any way to redefine styles by find and replace or script

    I have a some styles and i want  to change same things in all styles like language, align and numbers digit and etc....,
    So I ask if  there is an easy way  to do that except modify each style manual, like script?, I use inDesgin CS3, and CS4
    Like in Find Font there is option to redefine styles but that for fonts only, So there is way to do that by find and replace ?
    Thanks

    I'm not a "scripter" and I don't have a huge knowledge of what scripts are available, unlike some on here, but this is how I'd do it if I couldn't find what I wanted by googling.

  • A Script to Find and Replace Layer Names

    Are there any scripts to find and replace layer names?
    There is an excellent script available for Photoshop which allows you to not only replace words in layer names, but also insert words as Prefixes, Suffixes and Sequential Numbers.
    The illustrator version of this script only allows sequential numbering: It doesn't offer find and replacing of words.
    Ideally, it would be great if there was something that could do multiple find and replaces in one go:
    (e.g.
    You have layers like this Car, Dog, Bat
    You enter: car(Option1), dog(Option2), Bat(Option3)
    Your layers then become: Option1, Option2, Option3).

    big_smile, that's a very good start! Step 1 of Learning How To Script is indeed, adjusting an existing simple script to make it do more complicated things. (And usually then "break something", which is also a required part of the process.)
    You are correct in your observation this is repetitive stuff. For one or two different items that wouldn't be a problem, but in longer lists you soon get lost.
    The usual way of working with find-change lists is to build an array:
    var layernames = [
    [ 'FHairBowlBoy *Hair', 'Hairboy1' ],
    [ 'FHairCurlyafroBoy *Hair', 'Hairboy2' ],
    [ 'FHairSpikyBoy *Hair', 'Hairboy3' ],
    The general idea is to loop over all names, check if the current layer name is "layernames[i][0]" (the left column) and if so, rename it to "layernames[i][1]" (the right column). If you know how to write a loop in Javascript, then you can implement this right away.
    However ..
    A more advanced way to do this doesn't even need loop to over all layernames -- instead you can immediately "get" the correct name per layer! It's magic! Almost!
    The trick is to use a Javascript object instead of an array. Javascript objects are nothing special; Illustrator's 'layers' is an array of objects, and each object "layer" has a property "name", whose value you can read and set. What I do here is create a new object, where the "name" part is the original layer name and its value is the new layer name. All you need to check for per each layer is if there is a property 'object.originalLayerName', and if so, assign its value to that layer name.
    This looks a bit like the array above, except that (1) you use {..} instead of [..] to create an object, and (2) you add "name:value" pairs instead of "value" only (actually, the 'name' of a value in an array is simply its number).
    So this is what it looks like:
    // JavaScript Document
    var doc = app.activeDocument;
    // name indexed object
    var layernames = {
    'FHairBowlBoy *Hair':'Hairboy1',
    'FHairCurlyafroBoy *Hair':'Hairboy2',
    'FHairSpikyBoy *Hair':'Hairboy3'
    // loop through all layers
    for (var i = 0; i < doc.layers.length; i++)
    //Set up Variable to access layer name
    var currentLayer = app.activeDocument.layers[i];
    if (layernames[currentLayer.name])
      currentLayer.name = layernames[currentLayer.name];
    Enjoy!

  • Find and replace characters in file names

    I need to transfer much of my user folder (home) to a non-mac computer. My problem is that I have become too used to the generous file name allowances on the Mac. Many of my files have characters such as "*" "!" "?" and "|". I know these are problems because they are often wild cards (except the pipe). Is there a way that I can do a find and replace for these characters?
    For example, search for all files with an "*" and replace the "*" in the file name with an "@" or a letter? I don't mind having to use the terminal for this (I suspect it will be easier).
    Is this possible? Does anyone have any suggestions?
    Thank you in advance for any help you may be able to provide.
      Mac OS X (10.4.8)  

    Yep.
    "A Better Finder Rename" is great for batch file renaming.
    http://www.versiontracker.com/dyn/moreinfo/macosx/11366
    Renamer4mac may be all you need.
    Best check out VersionTracker. In fact everybody should have this site bookmarked and visited daily.
    http://www.versiontracker.com/macosx/

  • Enabling tabbing to controls on DW CS 4 Mac in Find and Replace

    I have used Dreamweaver on Windows for many years. I'm now working on the Mac.
    I have configured OS X Leopard for improved keyboard access to UI controls. This allows me to tab to dropdown (or popup) menu and use the keyboard to quickly select menu items. I realize this is a personal preference but personally I'm more productive this way. This setting affects the OS and appears to work in many applications. It doesn't appear to work in Dreamweaver CS4.
    I work on one PHP project that has hundreds of files. I routinely need to use Find and Replace to search in "Selected Files in Site" but often need to only search in "Current Document", so I'm routinely switching between these options. I'm also routinely toggle the "Use regular expression" option. On Windows I could change these settings without having to use the mouse. I could quickly tab (or shift-tab) from the "Find:" and "Replace:" text boxes to the "Find In:" and "Search:"  Dropdown Menus or the various "Options:" checkboxes, but find that one the Mac I have to use the mouse to change the dropdowns and checkboxes.
    Have I missed a Dreamweaver setting or a magic keyboard shortcut that would enable full keyboard access to DW's Find and Replace and other Dialogs?

    Yep.
    "A Better Finder Rename" is great for batch file renaming.
    http://www.versiontracker.com/dyn/moreinfo/macosx/11366
    Renamer4mac may be all you need.
    Best check out VersionTracker. In fact everybody should have this site bookmarked and visited daily.
    http://www.versiontracker.com/macosx/

  • Using + and - keys to change dates and times; Find and Replace event

    Hi all, \
    I have two iCal related questions. One has been bugging me since the Snow Leopard upgrade and the other I'm just wondering about.
    1. Is it just me or is it no longer possible to use the + and - keys to increment dates and times when editing an event? It seems that now I have to actually type in the numerals instead. Is there something in the preferences I'm missing or is that just the way it is now? Seems like a step backward, if so.
    2. Is there a way to do a "find and replace" for an event that occurs sporadically throughout the year, but isn't a repeating event per se? I just want to rename the event itself.

    Don,
    ...is it no longer possible to use the + and - keys to increment dates and times when editing an event?
    I did not know that was possible. Try using the ↑/↓ arrow keys to increment numbers, and →/← arrow keys to change fields.
    Is there a way to do a "find and replace" for an event that occurs sporadically throughout the year, but isn't a repeating event per se?
    AFAIK, you have to use the search field to find the individual events, and change them when you click on the events in the search results field.
    ;~)

  • Find and replace

    I have decided to do color correction and other retouching after I edit a multicam shoot. Is there a way to copy and paste the attributes of a clip to only certain clips in a sequence like a find and replace. I know how to copy and paste attributes, now I just need to copy the attributes of cam 1 to all the cam 1 clips, cam 2 to cam 2, and so on.

    It can save a lot of time. I find that even for simple close-up interviews, small movements can cause shifts in the lighting and exposure such that I often wind up customizing the color on many of clips after pasting on the filters.
    Be sure to use the scopes and range check when you are doing CC. I often use markers in my sequence for clips I want to use as a reference for color. The 3-way color corrector works well to balance out the different color and luma ranges of the image.
    Another fast way to get the filter on lots of clips at once is to drag one from the filters tab to make a favorite you can rename, then drag it from there onto a selected batch of clips in the timeline. Sometimes it's easier to apply filters this way to smaller batches of clips, rather than try to manage automatically selecting all the clips from that angle or camera all at once.

  • Find and replace global variables

    Hi there,
    I've ran into a mess with my global variables. While I was trying to rename one of the globals, all instances in hundreds of subvis turned corrupt. The icon of the global variable turned black and the wires starting at the variable became broken. The amazing thing is that the black icons seem still to be linked to the correct global variable. If I leave the mouse cursor on the icon, the correct file path appears in the context help window. If I double click on the corrupt icon, the correct vi is opened. I tried "Save as" and "Rename" with various options. LabVIEW seems to browse through all affected vis but the icons remain broken. My last hope was to run the "Find and replace" tool (Ctrl + F), but it doesn't work for global variables for some unknown reason, unfortunately. Compare
    http://forums.ni.com/ni/board/message?board.id=170&message.id=438450&query.id=2151294
    Is anybody out there who has a useful hint?
    Peter

    stoeckel wrote:
    Hi there,
    thank you all for your contributions. We were able to solve the problem in the meanwhile. Why did nobody point us to the fact that the icons of global variables turn black if the name of the control on the panel of the variable does not match the selected name inside the icon?
    The LabVIEW compiler would have told you that right away. If you click the broken run arrow on the situation you will get the message:
    An item with the specified name could not be found. Select a different item from the list.
    Seems pretty straightforward to me. But then, perhaps it's because I've been using LabVIEW for some time.
    If somebody just quietly mentions the existence of "global variables" he or she will usually be soused with flout and bashed by the proven active veterans. But why's that? Global variables can provide an easy way to communicate a "stop" information throughout all running vis. As long as there is just one writer and many readers, there is no danger that it comes to "race conditions".  
    If global variables are really so nasty as is often said, why does National Instruments still provide them within LabVIEW??
    I don't want to get into yet another global variable debate here. The only comment regarding global variables made in this thread was a tongue-in-cheek comment I made. I was not dissing global variable. In fact, I use them quite often. Global variables, like every other programming construct ever invented have their use. The main reason you will see the so called "proven active veterans" go crazy over global variables is that they constantly see them being abused, causing race conditions, and then have to listen to newbies complain that their program doesn't work and LabVIEW sucks, when it's really their programming skills that's the real problem. But that's just my opinion.

  • Find and replace advanced help

    Firstly thank you for reading.  I come here as a last resort to see if there's a solution to a problem I have.
    Basically I need to rename several thousand images in a blog backup that is being transfered to a new host.  The format of the images are as follow
    <img alt="Revlon-pedi-egg" border="0"  src="images/6a00d8341c873353ef011572419566970b-800wi.jpg"  />
    where each of the several thousand images has a unique alt tag and a unique image name
    What I want dreamweaver to find the alt tag then replace the image name, so that the above image would become
    <img alt="Revlon-pedi-egg" border="0"  src="images/Revlon-pedi-egg..jpg" />
    I have used replace expressions before as well as (.*) etc but I just can't seem to get this one to work.
    Is this possible and if so would someone be kind enough to give me some pointers?

    FIRST MAKE A BACKUP.
    Test this in several pages first.
    In Dreamweaver Find and Replace, select the following options:
    Find in: Current Document
    Search: Source Code
    Find:
    <img alt="([^"]+)(".*?)src="images\/[^.]+
    Replace:
    <img alt="$1$2src="images/$1
    Select Use regular expression.
    Once you are confident that it's making the correct changes, you can then do it for an entire folder or the whole of the current site.
    This assumes that all your image tags use double quotes around attribute values as shown in your original post.

  • Find and replace a single global variable

    Hello,
    I have a GUI which needs to be replicated 10 times. the variables in the global file also needs to be replicated ten times. ex: if GUI1 is using global variables GUI1_TestMode, GUI1_Result etc,  GUI2 should use GUI2_TestMode, GUI2_Result and GUI3 should use GUI31_TestMode, GUI3_Result etc.  So, once I have saved GUI1 as GUI2, I need a way to select all GUI1_TestMode in GUI2 and replace it with with GUI2_TestMode.
    I tried find and replace in the edit menu, but it finds all the global variables together. 
    there are about 40 such global variables associated with each GUI and I dont think it will be sane to sit down, rename all of them in the global file, click on each variable and change them.  I really hope I dont have to do that.
    I am using Labview 8.6
    Thanks.

    Hi pcs,
    instead of using 40 globals per GUI with upto 10 different GUIs you really should redesign your program.
    I would suggest a FGV/AE handling those global data for all of those GUIs…
    The quick & dirty way would be to use LabVIEW's VI linking scheme:
    - Create your global VI with all needed variables. Create your "GUI" and connect it with that global VI.
    - Now you copy your GUI to create a new one, this will still be linked to your "global VI".
    - Then copy the global VI to create a new instance with a different name ("global2.vi") and ZIP (and remove) the original one.
    - When you now open the global2.vi it will search for your orginal "global.vi". Then you simply direct it to use "global2.vi" instead…
    - Repeat those steps for all other GUI-VIs…
    As said before: QUICK & DIRTY!
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • "Find and Replace" for field names in a fillable PDF

    Is it possible to do a "Find and Replace" for the field names in a fillable PDF? For example, I have multiple fields that contain the word "Proposed Insured" as part of the field name and would like to find and replace all of them with "Owner". Is there an easy way to do this?

    Not really. Even a script can't just rename a field. It needs to create a
    new field on top of the old one, but then you lose all the associated
    settings, like validation, calculation, format, keystroke, etc.

  • Find and Replace Issue Help Requested.

    Hi all. I've been digging around for a couple of days and
    can't seem to figure this one out. For starters, I have already
    looked at the Regular Expression syntax and tried the MS word
    clean-up option, but no luck. We have about 1,500 pages of content.
    They are in DNN, so the pages are created dynamically.
    Unfortunately, the page content was written in Word and then dumped
    in DNN. We are trying to clean up the pages. We are grabbing the
    content from Dot Net Nuke and putting it into Dreamweaver 8.0.2.
    Then we are manually cleaning out things like:
    <?xml:namespace prefix = o ns =
    "urn:schemas-microsoft-com:office:office" />
    and
    <P class=MsoNormal style="MARGIN: 0in 0in 0pt"
    align=left>
    We are using the Find and Replace funtion in Dreamweaver to
    clean out these commands, but I know from the documentation, there
    is an easier way to clean these pages.
    Bottom Line: Since the pages are dynamically built, I know I
    have to grab the page content and put it in Dreamweaver manually
    and then put it back in DNN, but I am trying to find a way (using
    Regular Expressions or something) to look for all the little
    variances of MSO, <?XML, etc. in a straight shot. I would like
    to find a way to use a wild card to look for all tags that have MSO
    or Microsoft or ?XML in them and then replace them with a null
    value. From what I can tell, the Find would have to use a wildcard
    because the advanced find features don't carry what I am looking
    for. Something like Find \<?xml * [<-wildcard] to \> to
    grab the entire tag. The Find tag command doesn't work because the
    tags I need aren't listed. Also, because the content is dynamic, I
    can't do a Fins and Replace against the entire site for these
    commands, but it would be nice to "Find" all of these items with a
    single pass since the "Replace" value is always null.
    The wildcard syntax and multiple Find instances are the main
    questions. The wildcards seem to be character or space specific.
    Sorry for the long explanation - I just don't want to waste
    anyone's time typing responses to things I've already tried to do.
    Thanks in advance for any help. This is my first time back in
    the forums in about 4 years.

    sadamec1 wrote:
    > Well David, you Findmaster - it worked! (At least it
    found and highlighted the
    > code). Now, I need to dig through what you sent me and
    compare it against my
    > regular expression definitions to find out how to grab
    the rest of these
    > phrases. You're the best. Thank you!
    Glad that it did the trick. Just to help you understand what
    I did,
    there are two main sections, as follows:
    <\?xml[^>]+>
    and
    <[^>]+(?=class=Mso)[^>]+>
    They are separated by a vertical pipe (|), so they simply act
    as
    alternatives.
    The first one searches for <?xml followed by anything
    except a closing
    bracket until it reaches the first closing bracket.
    The second one is more complex. It begins with this:
    <[^>]+
    This simply looks for an opening bracket followed by anything
    other than
    a closing bracket. What makes it more intelligent is the next
    bit:
    (?=class=Mso)
    This does a forward search for "class=Mso". It's then
    followed by this
    again:
    [^>]+>
    That finds anything except a closing bracket followed by a
    closing bracket.
    The bit that you need to experiment with is (?=...). It's
    technically
    called a "forward lookaround". The effect is that the second
    half of the
    regex finds <....class=Mso....>.
    David Powers
    Adobe Community Expert
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    http://foundationphp.com/

  • Find and Replace in RH HTML

    After upgrading to RH8, all instances of "em dash" symbols in projects are now appearing incorrectly. When we insert the "em dash" symbol, we always eliminate any spaces before and after the symbol. All projects that have been upgraded to use RH8 now add a space after the symbol, which is incorrect.
    I have also installed the RH updates and opened a project that had not been upgraded before the update installs...same problem.
    Due to the size of the projects, I have tried using the Find and Replace feature within the HTML view; unfortunately, this did not work.
    Has this issue been addressed with Adobe? I ran into a similar issue with the upgrade to RH7, where the HTML coding for em dashes would come through in the design view and final .chm output file. Does anyone know of a Find and Replace feature within RH that will allow me to remove every instance where a space appears after the em dash symbol? I have found the FAR tool but would like to avoid it if possible, as I have read it can corrupt RH files.

    There was one other post recently about this but otherwise this problem had gone quiet so I don't know why you are seeing it in a project that was not opened before applying the patches.
    So turning to FAR, it is not the program that corrupts files. It is what the user does with it. As we usually say, it can fix a project in minutes and wreck it in seconds. That is because the user has not thought about what the search might find. For example, you might search for "class" thinking about your topic content but of course FAR works a code level so it will remove all your style classes as well. That is where the corruption comes in, not the software itself. It's rather like blaming the car for the crash.
    If you back up first, there is nothing to lose.
    See www.grainge.org for RoboHelp and Authoring tips
    @petergrainge

Maybe you are looking for

  • Mail with HTML BODY content?

    Hi, We seem to have a little problem with sending mails wtih HTML content, we have a "Link" in the mail body to be sent , so we are using html tags <a href=""link"></a> so that the mail receipient see the URL as a link .... The actual code used is gi

  • Visual Studio Online incorrectly assigns stakeholder licenses to MSDN subscribers

    We recently added on our Active Directory for Visual Studio Online. This has caused numerous challenges including a few folks with valid MSDN subscriptions stilling showing as stakeholders and thus preventing the ability to check in code. This has be

  • Hard drive dead with iweb site inside.  new iweb site replaced my old site!

    Is the old site a gonner? I had published the site with a personal domain, hosted with mobile me. When adding a new site, iweb replaced my old one. the old one was my business portfolio. the new one is just a single property advertisement. why dont I

  • About Reports

    Hi All, I run a query for which we have to enter a variable called 0Calday while we run a query. i ran the query and save in the excel. I dont remember at what date the query is ran and now I want to know the date. How can I know the date. Help me at

  • Configuring RPC dynamic port allocation

    I'm getting RPC errors to a Windows 2003 server: 0x800706ba Win32 The RPC server is unavailable I've verified the RPC, TCP/IP Netbios Helper, Windows management Instrument services are started on the 2003 box. From the same 2003 box I am able to run