A Script to find and replace the layer names
Is there scripts to find and replace the names of layers?
There is an excellent script available for Photoshop that allows you not only to replace words in layer names, but also insert words as prefixes, Suffixes and sequential numbers.
The version of the illustrator of this script allows only sequential numbering: it does not offer search and replace words.
Ideally, it would be great if there were something that could find multiple and replaces in a go:
(for example
You have layers like this car, the dog, the bat
You enter: because (Option1), dog (Option2), Bat (Option3)
Your layers become then: option 1, option 2, Option3).
)
Big_SmiLe, which is a very good start! Step 1 of learning how to Script is indeed, by adjusting an existing simple script to make things more complicated. (And usually then "break something", which is also a necessary part of the process.)
You are right your comment, it comes to repetitive things. For one or two different articles that wouldn't be a problem, but in the longer lists you are soon lost.
As usual to work with lists of search - replace is to build a table:
var layernames = [ [ 'FHairBowlBoy *Hair', 'Hairboy1' ], [ 'FHairCurlyafroBoy *Hair', 'Hairboy2' ], [ 'FHairSpikyBoy *Hair', 'Hairboy3' ], ];
The general idea is to loop through all the names, check if the current layer name is "layernames [i] [0]" (the left column) and if so, rename it "layernames [i] [1]" (the right column). If you know how to write a loop in Javascript, then you can implement this immediately.
However...
A more advanced method to do this didn't need even loop on all layernames - instead you can immediately 'get' the correct name by layer! It's magic! Almost!
The trick is to use a Javascript object rather than a table. JavaScript objects are nothing special; "Layers" of Illustrator are an array of objects, and each object 'sex' has a 'name' property, which you can read and set the value. What I do here, is to create a new object, where the part 'name' is the name of the original layer and its value is the name of the new layer. All you need to check each layer is if there is a "object.originalLayerName" property and if so, assign its value to this layer name.
It looks a bit like the table above, except that (1) you use {.} instead of [..] to create an object and (2) you add pairs "name: value" instead of 'value' only (in fact, the 'name' of a value in a table is simply her number).
So here's 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!
Tags: Illustrator
Similar Questions
-
Find and replace the script in Question.
Hi all
I searched for a way to show the amount of changes here? My script to find and replace is working however, I would like to see if there are changes 0 or 100 so that we know how much if any of the corrections have been made. Basically, I want to show him the same type of information as the (Native find replace in Indesign). If there is a link that talks about this please point me in that direction.
I found it... «changes var = ' must be set to the line in function changeGrep()...» I've got an example of script grep for you that replaces the word "December" 'Months' and alerts as to how many changes have been made.
app.findGrepPreferences.findWhat = "December";
app.changeGrepPreferences.changeTo = "month";
changes in var = app.documents [0] .changeGrep ();
var numChange = changes.length;
Alert ("the changes have been made." + numChange);
-
Find and replace the delimited string value by the
Hi all
I have a requirement where I need to find and replace the delimited string values.
For example, the string is "GL ~ 1001 ~ 157747 ~FEB-13~ CREDIT ~ A ~ N ~ US ~ NULL ~". The 4th column gives the month and year. I need to replace it with the name of the previous month. For example: "GL ~ 1001 ~ 157747 ~JAN-13~ CREDIT ~ A ~ N ~ US ~ NULL ~". I need to do the same thing for the past 12 months.
I thought initially divide the values and store it in a variable and then after him substituting the value required, join the return.
I just wanted to know if there is a better way to do it?
Like this:
with a model like
(select "GL ~ 1001 ~ 157747 ~ FEB-13 ~ CREDIT ~ A ~ N ~ $ ~ NULL ~' double UNION ALL data")
Select ' GL ~ 1001 ~ 157747 ~ JAN-13 ~ CREDIT ~ A ~ N ~ US ~ NULL ~' double data)
Select
REPLACE (DATA, TO_CHAR (to_date (substr (data, 16.6), "MON-RRRR"), 'MON - RR'), TO_CHAR (to_date (substr (data, 16.6), "MON-RRRR")-1, 'MON - RR'))
modeling;
GL ~ 1001 ~ 157747 ~ JAN-13 ~ CREDITS ~ HAS ~ N ~ US ~ NOTHING ~
GL ~ 1001 ~ 157747 ~ DEC-12 ~ CREDITS ~ HAS ~ N ~ US ~ NOTHING ~
Ishan
-
How can I find and replace the xml tags?
Hi, I am using xml in my workflow and want to be able to remove some tags if they contained particular text.
Here is an example of the xml struct...
< Entry >
< name > DEFAULT < / name >
< such > default < / such >
DEFAULT < address > < / address >
< / Entry >
I use this initial structure to define paragraph styles to follow when you import the xml data.
This leaves DEFAULT in place everywhere where an entry is not any content of this field.
I want to be able to import my XML and then run a script that deletes tags that include by DEFAULT, - I need to the xml tag to remove not only the text, if I do a normal find and replace will remove only the text not the tags that is causing problems with style. I also want to remove the end of para/return (^ p) that I placed at the end of the line. So it would be the same opening editor mode and removing content, tags + hard back in there, but I want to automate the process...
So I think that's what I'm looking for in each case
"< name > DEFAULT < / name > ^ p.
and I want to replace it with nothing.
Is this possible in a script (ideally javascript)?
I have a little knowledge of javascript, but don't know how to search for and target this kind of string in indesign...
using indesign cs5
Thank you very much
Hello
Script should do it in two steps:
1 find all occurrences of that is ' > by DEFAULT.<>
2 delete the whole paragraph which is a found_text container.
For example, in this way - JS - (a textFrame filled your text must be selected):
var mStory = app.selection[0].parentStory; app.findTextPreferences = null; app.findTextPreferences.findWhat = ">DEFAULT<"; var myF = mStory.findText(); var count = myF.length; while (count--) myF[count].paragraphs[0].remove();
Rgds
-
My apologies if someone already asked this (I couldn't find the answer however). I used the name of a person to dozens of (mostly Word) documents that are kept in many different files on my hard drive. I know that I can dig each document separately and then use hidden word and replace the tool to change the name. But this will inevitably take time. Is it possible to do a through - computer find and replace so that I don't have to do this exercise once? Any help gratefully received. Thank you.
Hello
I suggest you go through the article and check if it helps.
Searching in Windows Vista, part 1
Searching in Windows Vista, part 2
Searching in Windows Vista, part 3
Improve Windows searches using the index: frequently asked questions
Hope this helps and let us know if you need more assistance.
-
Find and replace the phone number on 1000 PDFs
Hello
Anyone know of a faster way to find and replace text (phone number) on a PDF, we have a 1000 needing PDF files
Edition, pitstop even can't do it quickly.
Thanks in advance
Paul
PDF files were not intended to be edited on such a scale. The only way that such a task can be automated is by the new text which is superimposed on the old, with fields or comments and then flatten the file. But if the location of the text changes a file in a file, or the length of the new text is not exactly the same as that of the former or the font properties are not known in advance, this becomes almost a mission impossible.
-
Find and replace the work of the Meta Descriptions?
If someone has found a way to make a site-wide find and replace, to access the Meta Descriptions, titles or embedded HTML? I am involved in a project of cloning of dozens of web sites Adobe Muse & change text in various areas. It would be a HUGE timesaver. Appreciate all the help that can be offered on this topic!
Thanks for getting back to me on that. Search for replacement & is great, but it's a disappointment that only the body of pages can use this function when it has so much important text in page descriptions and titles! I would love to see this feature added to a future version of Adobe Muse... Any chance you could forward that request to the right person to review?
Thank you!
Chris
-
I am a Mapper and converted from FreeHand to Illustrator several years ago. One thing I seriously need is the ability to take a shape and convert it into another form. That is to say to that I have several circles a certain size and color and I need to change all these symbols of a diamond of a different size and color. Freehand was graphic find and replace option where I could copy the original graphic and copy the graph to set up in what I wanted. Then I'll select all of the original graphics, replace hit and it would change WITHOUT moving forms as a whole.
This also concerns the ability to scale to a bouquet of circles in a single shot without having to go through each individual cirlce and scaling each.
Illustrator has the ability to do or things that I have just described? I searched the forums and can't seem to find an answer. This could help me (and I would bet thousands of other cartographers who have to export the data in ArcMap stylization!)
Thank you!
A good trick for when you use symbols is to draw a fill box & STROKE None in your symbol, bigger than your art. The position in this way as your symbol doesn't move, as long as your changes get no more large size the fill & STROKE no box. Saved me many hours over many jobs.
-
Find and replace the part of a url in the menu
I use a tesing server and have all my links in the pop-up menus that are linked. I'm about to go live and you want to substitute the name of the test server with the new true site name. Subdirectory names, and the page will be the same, just the domain part evolves. Is it possible to find and replace it in the world, or do I have to go into my png and redo every single link?You did your absolute links? Why?
--
Murray - ICQ 71997575
Adobe Community Expert
(If you * MUST * write me, don't don't LAUGH when you do!)
==================
http://www.dreamweavermx-templates.com - template Triage!
http://www.projectseven.com/go - DW FAQs, tutorials & resources
http://www.dwfaq.com - DW FAQs, tutorials & resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
=================="EVN"
wrote in message
News:e64uf9$7LP$1@forums. Macromedia.com...
> I use a tesing server and have all my links in the related pop-up menus
> to
> it. I'm about to go live and want to replace the tests
> server
> name with the new name of the real site. The subdirectory names and page
> the
> even, just the domain part is changing. Is there a way find and replace
> This
> in the world or what I have to go into my png and redo every single link?
> -
Find and replace the anchored frame properties
Using FrameMaker 11, is it possible to use find/replace to find each image rooted and apply a black Pen 1 pt template to each image?
Start by creating the appropriate style for the frame anchored using the new object Styles option in FM11. Then use find it > anchored frames and apply the style manually. You can use the 'esc g e' hotkey to quickly catalog object Style and then apply your style preset to the anchored frame.
Unfortunately, you can not make a special copy to recover the object Style so that you can use the paste option in the replace/find.
-
Case-sensitive option in find and replace the chain
Hello!
Attached is my problem.
I'm looking 'toto' in the 'toto + tototi' input string and replace 'toto' by 'A0 '.
I want to "respect" the input search in order to get a string result: A0 + tototi
Are there options allowing for case-sensitive option?
BR,
VincentYou use search and replace with Regular Expressions selected (the little asterisk icon). \b represents a word boundary, basically the imaginary space between the character is a letter, number or underscore, and the other is not. In other words, it is an assertion of width zero, which means that \b does not capture anything.
For example: toto is toto, toto1, toto_1 etc. toto\b matches the string 'toto' when it is followed by something that is not alphanumeric or underline, is why it will not match toto1 but will match toto + or 'toto '.
Go to pcre.org for more information or follow the assistance detailed in LV I assumed you knew because you need to turn on Regular Expressions in S & are so I assumed that you had done. You've probably done without being aware of what you were doing.
-
Find and replace the string function replaces line breaks when I only replaced spaces?
I need to replace all instances of a space or a series of spaces to a line with commas (or tabs) multi string so I can throw in a worksheet.
I use the regular expression [\s]+ and it works, but it is also to replace the end of lines (\r\n) too.
How can I replace the spaces but leave the end of the lines intact?
Right-click on the search string and to take '-' code display. Enter the space character (\s) correctly - you \\s right now.
-
Find and replace the necessary assistance to the removal of several Word Bookmarks
I am importing a Word document sections. Word documents have favorites such as:
< h3 > < a name = "_Toc226886762" id = "_Toc226886762" > fixed-variable < /a > < / h3 >
I would like to do at the level of the site search and replace, delete all bookmarks (they all start with table of contents) but keeping the title and the text format. I tried several options, but nothing works.
Thank you.
I just copied and pasted the code in an HTML document, and ran the search and replace regular expressions. He removed all four bookmarks without problem.
I see that you say you copied and pasted my regex in the search field. I just do the same thing and see that when you use copy / paste, the cursor in the search field ends up on a new line. Press BACKSPACE to get rid of the new line. It should then work.
-
How can I adapt this script GREP to find and replace the current open document?
// Get the current selection var doc = app.activeDocument; var sel = doc.selection; var frame = sel[0]; if (!frame || frame.constructor.name !== "TextFrame") { var msg = "Please select a text frame containing"; msg += " the story you wish to format"; alert(msg); } else { var story = frame.parentStory; // Reset the Find/Change options app.findGrepPreferences = NothingEnum.nothing; app.changeGrepPreferences = NothingEnum.nothing; // Remove all soft returns, then replaces all double spaces to single spaces app.findGrepPreferences.findWhat = " \s+\n"; app.changeGrepPreferences.changeTo = " "; story.changeGrep(); // Remove all multiple spaces app.findGrepPreferences.findWhat = "\s+"; app.changeGrepPreferences.changeTo = " "; story.changeGrep(); // Split Listings WITH Images app.findGrepPreferences.findWhat = "(\d\d-\d+.*)\t(?!~a)(.*)\t(.*)\r"; app.changeGrepPreferences.changeTo = "$2\r$1\t$3\r"; app.changeGrepPreferences.appliedParagraphStyle = "Description"; story.changeGrep(); // // Split Listings WITHOUT Images // app.findGrepPreferences.findWhat = "(?<=~a)(.*)\t(.*)\t(.*)\t(.*)\r"; // app.changeGrepPreferences.changeTo = "$1 $2\r$3\t$4\r"; // app.changeGrepPreferences.appliedParagraphStyle = "Description"; // story.changeGrep(); // Format Pricelines app.findGrepPreferences.findWhat = "^(\d\d-\d+-\d\t.*)\r"; app.changeGrepPreferences.changeTo = "$1\r"; app.findGrepPreferences.appliedParagraphStyle = "Description"; app.changeGrepPreferences.appliedParagraphStyle = "Priceline"; story.changeGrep(); }
Hello
story.changeGrep (); ==> This sets a goal of change
To replace it any doc as target
doc.changeGrep ();
and remove part of the code that is cause of selection type do not need you to check
Jarek
-
Find and replace the name of the various signals of different value
Dear members
I run a program where I get the output signal ' displacmentrange 1 '...
"displacementrange 19" I need to replace this name with another name
for example
When come signals
displacementrange 1, it should show 122.5nm
displacementrange 1, he must show 245 NM
displacementrange 1, he must show 490 nm
concerning
Benoit zafar
Hello deutchland.
I hope that I have understood correctly, you can use find in table and then use the array index
Maybe you are looking for
-
Firefox crashes when I try to insert an attachment to webmail (E-mail BT)
I also use IE11, who is happy to locate and to accept attachments - usually Word 2010 documents - emails sent by mail from BT.
-
Incremental Quadrature encoder
Hello I use an encoder incremental quadrature. I ran the position.vi of angular measure in the examples to find > measure angular position.vi However, I always get the angle between within 360 degrees. How to obtain the more than 360 degrees (i.e. If
-
Original title: windows xp 512mg 160 GB how to install adobe reader I can't install or get adobe reader, it says - check hotfix package hotfix for the Installer package valid window do - what I do?
-
G70-111EM - wireless works only with Windows 7 Professional
Dear users, After 1002 in the factory reset error and not be able to solve this problem. I decided to buy Windows 7 and install it on my laptop, G70-111EM. The problem I have now is that I can not can not to wireless internet with. Wired LAN connect
-
How to print on legal paper with my Officejet Pro 8600?
I have an Officejet Pro 8600. It has a single paper tray that will not grow to hold legal size paper. I could stuff a few sheets of legal size paper in the tray and close it, but the printer will print only top 11 "of the page. What can I do to be