A loop through hyperlinks and add * at the end of the hyperlink source text?

Hello

I'm sure it's very simple, but my javascript is a little rusty and a little short of time, so I was wondering if someone could point me in the right direction?

I need a script that loops through all the hyperlinks in a document (no matter what styles are or are not applied). Please check the source text to see if it starts with "www" or "http".

If the source text starts with "www" or "http" then do nothing. OTHERWISE add an * at the end of the text. In other words if there is text in the document as "Click on this link" (and there had a hyperlink applied) it would be changed to "click on this link." If there is text in the document as "www.google.com" (and there had a hyperlink applied), it would remain unchanged. The hyperlinks themselves remain unchanged.

So I'm not sure what my If/else statement must be?

Links = app.activeDocument.hyperlinks;

for (i = 0; i < links.length; i ++)

{if

???

}

Thank you very much in advance for your help!

Angèle

How stupid. You are absolutely right. The names of hyperlink above, test script must test the hyperlink source texts. In the small sample, I have tested the script on, names of hyperlink and source texts were the same, that's why I had not spotted the questionable logic of the script. This scripts properly tests:

hlinks = app.documents[0].hyperlinks.everyItem().getElements();
re = /^(?:http|www)/;
for (i = hlinks.length-1; i >= 0; i--) {
  if (hlinks[i].source.hasOwnProperty ('sourceText') && !re.test (hlinks[i].source.sourceText.contents)) {
    hlinks[i].source.sourceText.contents += '*';
  }
}

This would also explain the unexpected behavior of your / ^ j / test. (/ ^ j / tests whether a string starts with 'j' - no need to the * or the parentheses.)

Peter

Tags: InDesign

Similar Questions

  • Suddenly, my sound card does not work - try the devices and add/install the old hardware on the Assistant Manager, he finds ADSInstant HTV PC1, but sending the message... Impossible to install correctly the code 10

    tried the Device Manager and add/install the old hardware on the wizard... he finds ADSInstant HTV PC1, but sending the message... Impossible to install correctly the code 10

    Restore the system to then it was working properly.

  • Import: Copy Photos as Digital Negative (DNG) and add to the catalog

    I am importing existing (on disk) Camera RAW (.) CR2) photos in Lightroom.

    I read that it is a good idea to convert Camera RAW files to DNG, so I chose the option copy Photos as Digital Negative (DNG) and add to the catalog.  I also chose to backup the files when you import on an external drive.  DNG files that are created are copied into the new central repository on my hard drive where I keep all my photos that are managed by Lightroom.  The original. CR2 files are left where they were originally.

    I have two questions:

    1. is there a justification to keep the original. Cr2 files in the old file once I converted to DNG in the new central repository?

    2. When does the backup import Lightroom backup of the original. CR2, DNG format files on my external hard drive. Does make sense?  If the disk containing my. How can DNG photos breaks down, I use the container backup. CR2 files if Lightroom is expected to make them. DNG ones?

    Thanks for the ideas!

    acresofgreen,

    Of course, it is a matter of opinion, but once you've decided to switch to DNG, and you converted your CR2 files, I would empty the original CR2 on DVD files, I hope never to be looked at again.  Then include your DNG in a normal backup routine that includes an external hard drive on the spot and online, the off-site source as well. The backup in place when importing is not intended to save the newly created, just DNG the imported the files themselves.  In rare cases, the conversion of the DNG format has a little problem and until you have a chance to look at each image, keep the original CR2s somewhere, but not necessarily easily accessible, is logical. My backup, comments also to point 1 above.

    The f

  • Script to add description and keywords to the files of text file

    If anyone can write something for me? I must say I can't do it myself, I don't know Javascript.

    I need to add keywords and a description to 1000 pictures. I have a file of text formatted as such for each 100 images. The script will have to request an input file (or I cannot hardcode the path in the script) and apply to the folder being images in bridge.

    Example of a text file:

    1000 Bright Sunset Over City. (sun city sky; mountain;).

    1001 - Dawn Behind mountain and Lake. (Sun Mountain water; sky;).

    1002 - red sunset, sharp light of the bright clouds. (Sun sky tree; clouds;).

    1003 - tree framing Sunset Over the Bay. (tree; Sun Lake; Bay;).

    1004 - Sun Behind Seagull on stilts. (Seagull; Sun sea; stilts;).

    images are named 1000.tif, 1001.tif, 1002.tif etc.

    Running on a Mac with CS3 and CS4.

    Thank you

    Chris

    Thank you very much, David, I have to read more about these things, I modified the script you wrote.

  • SELECT and add to the release of e-mail

    Hi guys,.

    I am trying to take the records in a table and place them in an email to myself. Works by email basis (without any select statement) so the question is recovering and by including the data in the table. My code is:
    DECLARE
      v_From      VARCHAR2(80) := 'C3.Weekly';
      v_Recipient VARCHAR2(80) := '[email protected]';
      v_Subject   VARCHAR2(80) := 'HKADM C3 Stats Fail - ' || to_char(sysdate,'DD') || ' ' || 
            rtrim(to_char(sysdate,'Month'), ' ') || ' ' || to_char(sysdate, 'YYYY');
      v_Mail_Host VARCHAR2(30) := 'smtp.XXX.com';
      v_Mail_Conn utl_smtp.Connection;
      crlf        VARCHAR2(2)  := chr(13)||chr(10);
      db_fail VARCHAR2(4000);
    BEGIN
    SELECT DISTINCT TBS_SVC_NAME into db_fail
           FROM hkadm.TBSTAT
           ORDER BY 1;
     v_Mail_Conn := utl_smtp.Open_Connection(v_Mail_Host, 25);
     utl_smtp.Helo(v_Mail_Conn, v_Mail_Host);
     utl_smtp.Mail(v_Mail_Conn, v_From);
     utl_smtp.Rcpt(v_Mail_Conn, v_Recipient);
     utl_smtp.Data(v_Mail_Conn,
       'Date: '   || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf ||
       'From: '   || v_From || crlf ||
       'Subject: '|| v_Subject || crlf ||
       'To: '     || v_Recipient || crlf ||
       crlf ||
       
    ' The following databases failed to commit:');
     utl_smtp.Quit(v_mail_conn);
    EXCEPTION
     WHEN utl_smtp.Transient_Error OR utl_smtp.Permanent_Error then
       raise_application_error(-20000, 'Unable to send mail: '||sqlerrm);
    END;
    /
    I get the error "ORA-01422: exact fetch returns more than requested, number of lines and ORA-06512: line 11. Then, I thought that maybe I had to make a loop on the variable but then he complained that there is a FOR: s any help appreciated.

    Mike

    Hello

    It seems that you get several lines that is not possible to store in a variable 'db_fail '.

    How about using the loop in a cursor.
    for example:

    Declare
    cursor c1 is SELECT DISTINCT TBS_SVC_NAME
    OF hkadm. TBSTAT
    ORDER BY 1;

    Begin

    FOR db_fail in c1
    LOOP
    v_Mail_Conn: = utl_smtp. Open_Connection (v_Mail_Host, 25);
    UTL_SMTP. HELO (v_Mail_Conn, v_Mail_Host);
    UTL_SMTP. Mail (v_Mail_Conn, v_From);
    UTL_SMTP. RCPT (v_Mail_Conn, v_Recipient);
    UTL_SMTP. Data (v_Mail_Conn,
    ' Date: ' | TO_CHAR (sysdate, ' Dy, hh24:mi:ss DD month YYYY ') | CRLF.
    ' De : ' || v_From | CRLF.
    "Subject: ' |" v_Subject | CRLF.
    ' De : ' || v_Recipient | CRLF.
    CRLF.

    "The following databases could not commit :');
    UTL_SMTP. Quit (v_mail_conn);

    END OF LOOP

    See you soon
    Anurag Tibrewal

  • How to recover the machines VMS and add to the inventory

    I have this problem, either because I'm stupid, ESXi has limited features. I hope this is the first

    I use an Active Directory on ESXi 4.0 test lab and I just killed the domain controller. I've been lying to move VM to another data store and I did, the hard (20 GB) file is now stored on the main data store, which is supposed to be in use. Problem is that I can't apply this in VM vmdk file.

    I tried two different ways;

    1. I created the new virtual machine and chose to use an existing, traveled this hard drive but it is not recognizable. When you browse the data store, virtual computers work vmdk files have an icon. This one has a blank white icon.

    2. I created a new virtual machine with the hard drive. Then, I deleted the new hard and just replaced an old, renamed correctly. In this way VM does not start, complaining about this is not virtual disk.

    Is it possible to restore this domain controller?

    You cannot rename the EXSi VMDK file, otherwise the vmdk file is unable to climb to the top.

  • Data Currency Adjustment of entity are not copy through rule when we used the value source as "ECT."

    Hi all

    Data Currency Adjustment of entity are not copied through rule when we try to copy the data from one entity to another entity for the same account if the account is to have only the data entity Currency Adjustment but rule the data copied correctly when the entity is to have Exchange entity adjustments and currency of the entity.

    Wrote the rule to copy the values from the source account ' entity currencies Total "to target the currency of the account"entity ". Rule works as follows:

    1. If the source account's currency of the entity and entity Currency Adjustment, total value ECT (EC + ECA) copy correctly to currency of the entity to the target account. -OK

    2. If the source account's single currency entity (has no entity value Currency Adjustment) then under rule copy data properly to account currency of the target entity.  -OK

    3 but if the source account has only entity Exchange adjustments (has no value of currency of the entity) and then under rule is not copy of account currency of the entity of the target data. -Requirement

    Could you please see the rule below and please suggest possible solution to copy the Court of Auditors with the help of ECT when the source account has only ECA.

    If Hs.Entity.Member = "120006_ALTER" and HS. Value.Member = "Currency entity of <>" Then

    HS = IS_Account. Account.List ("NetProfit", "[Basic]")

    For each Account1A in IS_Account

    Set dataUnit HS =. OpenDataUnit ("E #120006.A #" & Account1A & ".") W #YTD")

    numItems = dataUnit.GetNumItems

    If numItems > 0 Then

    For I = 0 to numItems-1

    Call dataUnit.GetItem (I, vAcct, ACIP, vCust1, vCust2, vCust3, vCust4, AllocAmt)

    If AllocAmt <>0 then

    GSA Exp "A #" & Account1A & "=" & _

    «E #120006.V # < entity Curr Total >.» "A #" & Account1A

    End If

    Next

    End If

    Next

    End If

    Thank you

    Mahesh

    I thank very you much for the quick response. I tried with the above but no luck.

  • To increase the memory in my computer, I just get another memory card and add to the empty slots next to the already existing PC memory?

    I have 1 GB of RAM windows vista. It is rather slow. I would like to as DIY from 1 GB RAM to 4 GB. You just not sure if I would add simply individual 1 GB of memory for places on the motherboard to make 4 GB?

    Hello

    as you have only 1 GB of RAM, you could try readyboost as a less expensive alternative

    Read about the use of a flash drive for performance at the link below

    http://www.bleepingcomputer.com/tutorials/tutorial136.html

    and if you want to increase the RAM on your motherboard, use the crucial scan which you tell what is the compatible type and the size of RAM for your motherboard

    http://www.crucial.com/

  • I export to a jpeg file and add to the cat but if I do a sync after that he wants to delete it

    If I export a raw to jpeg format in the same folder update catalog it all works, but if I do a sync folder after who want all my exported jpeg should be deleted.

    Our administrator of the LR group tried this as well and got the same results. I'm on 5.7.1 on 5.2 and we both experienced users. Because normally I export my JPEG files in a separate folder in the catalog I didn't notice it earlier, but I was actually a test for a user with a similar problem involving edit in PS and lose the tif.

    Synchronization of folders is sort of an IMPORT statement so maybe he respects the parameter "treat JPEG files files next to raw as separate photos" in the preferences.   Put him in power and see what happens.  With it turned off the synchronization will delete the Lr jpg file as you say.  With the preference off she probably should remove the photo even if there is a setting to not to in the Synchronization dialog box.  I didn't test too as far as my workflow does NOT keep jpg is the same folder as the RAWS.

  • A loop through to produce statistics (insert the included script/code)

    Hi, I hope someone can put me in the right direction, because I'm not sure of what I should look for on Google to accomplish my task.

    Basically, I have a table for example (sorry first time provides a script like this, hope, it works!)
    create table dl_loop_test (
    id_key varchar(2) primary key,
    completed varchar(1),
    cat_type varchar(2));
    
    insert into dl_loop_test values
    ('1', 'Y', 'AB');
    insert into dl_loop_test values
    ('2', null, 'AB');
    insert into dl_loop_test values
    ('3', 'Y', 'YZ');
    insert into dl_loop_test values
    ('4', 'Y', 'YZ');
    My goal is to be in return an array with the statistics of my data such as:

    TYPE - COMPLETED_ % - TOTAL-
    AB--------50%---------------2-----------
    YZ--------100%--------------2-----------

    So currently I use just stats from where clauses matching "AB" or "YZ".

    The problem is that my real data have 30 + combinations, and I intend to execute different queries though, overall, that it will be quite of your time.

    Is there an easy way to browse it?

    thedunnyman wrote:
    The problem is that my real data have 30 + combinations, and I intend to execute different queries though, overall, that it will be quite of your time.

    Unless I'm missing something, it's clear GROUP BY:

    select  cat_type,
            (count(case completed when 'Y' then 1 end) * 100 / count(*)) || '%' completed_pct,
            count(*) total
      from  dl_loop_test
      group by cat_type
      order by cat_type
    /
    
    CA COMPLETED_PCT                                  TOTAL
    -- ----------------------------------------- ----------
    AB 50%                                                2
    YZ 100%                                               2
    
    SQL>
    

    SY.

  • Economy and search for files and add to the album.

    I have an album and worked on a sequence of photos. As part of the workflow, I save a jpg and psd file before final backup. Each saved file is in the folder the original file resides in.

    My problem is, when I get back later, perhaps only 10% of the files are there. There is not the faintest idea where are the psd or jpg "worked on".

    In addition, whenever I restart item editor, the list of recent files has been removed.

    This is the nastiest ever made software or I make huge mistakes while using it?

    Edit * just realized the files are there, but they are not now show in the catalogue. The catalogue clearly doesn't update itself, and I do not know how to update.

    The other weird thing is that I was using a picture as a background. The folder that resides in, thumbnails of images worked on what I did so far, but with circles with a line throuhg in the upper left corner. It's very weird

    When you use "Save as", you must check the box 'save in the Organizer. This saves the new file into a set of version.

    In the menu "Edit", "preference" also in the "Save" the article you have "save to the original folder" checked.

  • Help me to change user name and password on the login page text

    Hi all

    My requirement is to change the username and password text on the UID and PWD connection page

    I followed the steps in the Guide of Oracle Access Manager Customization Chapter 4

    But he is not having changed in the login page

    Please help me

    Thank you.

    Published by: user10648177 on December 1st, 2008 01:02

    Hello

    What you really need to do is edit the oblix/lang/en-us/msgctlg.xsl file, change the values of the variables MUserName and MPassword as you want and restart the server identity. Of course, if your language is not en - us, you need to interpret the above path accordingly.

    Where did you find the instructions you need to change the oblixbasemsg.xml?

    -Vinod

  • No idea how to loop and add the value to the attribute of the xml node?

    I work on a lot of flattening of project using a watched folder.

    I have a process parent to locate the directory and call a sub-process to flatten PDF files.

    I want to write the directory failed to XML.

    If there are several directory failed locations and if I want to add it to the node, he doesn't let me do.

    If I set the Xpath location like/process_data/outputXML/flattenDirectoryRequestMessage/failureFileLocation[x]/@path it gives me invalid character exception. I use 'x' for looping and incrementing.

    If I do not use the [x]. The directory is overwritten.

    No idea how loop and add all the directories failed to attribute of the xml node?

    I understand that you can not browse the xml code to assign the value at each node. Rather you can assign only one time to the node.

    I realized that it is not possible to do it this way. Then concatenate it as strings, and then attach to the xml once.

  • Recursive loop through the file system.

    Hello!

    I'm trying to figure if Javascript is my answer to my problem.  I have been able to re - write all my AppleScript scripts that manipulate Illustrator with the exception of those that he had to use the file system.  We stayed in PC at work and now I have to figure this out.  Our art files are saved with a number of 7 digits, followed by the name of art in the file.  Ex: 1000049-Bob Garage.  My applescript had a recursive loop that worked its way down through the structure of the files on our server art until it finds the record low where it belonged, then saved in itself.  Here is an example of how the structure of server files (these are the folder names) is extended:

    1000000-1004999

    1005000-1005999

    1010000-1014999

    and so on.

    The script would load all foldernames in the first level of the directory, loop through them and watch the first and last name of each of these folder names, then compare the Illustrator file name to them.  If my file is between the two, then the loop itself, called loaded the files inside of that folder and in doing so, working its way down through the folders through the tree structure until there where records is no longer.  At this point, the file was saved, in the order, where it should be.

    I have no idea on how to start this task with Javascript, if this is possible even with a language developed for browsers.  I'm with other people who are frustrated by such a widely adopted language, if little info is available on its use outside the browser.  If anyone can tell me all resources dealing with Javascript programming of the file system, or even to have the kindness to write this little monster for me, I'd always in your debt!

    Thanks in advance for any time you spend with this problem!

    Open the ESTK, and then on the Help menu, you will find a link to the Javascript Tools Guide. You will find everything that you need in Chapter 3 file system access.

  • Read multiple files in the folder and add data to a file

    Hello world

    Normal 0 false false false MicrosoftInternetExplorer4 / * Style Definitions * / table. MsoNormalTable {mso-style-name: "Table Normal" "; mso-knew-rowband-size: 0; mso-knew-colband-size: 0; mso-style - noshow:yes; mso-style-parent:" ";" mso-padding-alt: 0 cm 0 cm 5.4pt 5.4pt; mso-para-margin: 0 cm; mso-para-margin-bottom: .0001pt; mso-pagination: widow-orphan; do-size: 10.0pt; do-family: "Times New Roman"; mso-ansi-language: #0400; mso-fareast-language: #0400; mso-bidi-language: #0400 ;} "}

    I have several (hundreds) text files in a folder. I want to combine the data of the files into a single file. It must of course begin to file the oldest and sequentially read the files to the latest changes and add all the data in a new txt file.

    Here are the typical two consecutive files comma separated data:

    2009-02-17, 23:17:04, ff1c, 00ff, 0093, 0000, 0100 and 0001-ffff, d3ae, 0cce, 0 cd 4, DC 4, 00 c 2 0, 000 a, 09e4, 0609, 0000 and 0000, 17 c 7
    2009-02-17, 23:17:06, ff1c, 00ff, ffff 0093 0100, 0000, 0001, d3af, DC 0 5, 0 cd 7, 0ccf, 00C 2, 000e, 09e6, 0608, 0003, 0000, 17 c 7
    2009-02-17, 23:17:09, ff1c, 00ff, ffff 0093 0100, 0000, 0001, d3b0, 0 cd 2, cd 0 1, 0 cd 5, 00bb, 000d, 09f1, 0608, 0000 and 0000, 17 c 7
    2009-02-17, 23:17:11, ff1c, 00ff, 0093, 0000, 0100 and 0001-ffff, d3b1, 0c 21, 0ccf, 0 cd 3, 00 c 2, 000 a, 09e3, 0608, 0000 and 0000, 17 c 7
    2009-02-17, 23:17:14, ff1c, 00ff, ffff 0093 0100, 0000, 0001, d3b2, 0cc9, DC 0 5, 0 cd 7, 00 c 4, 0008, 09e4, 0608, 0000, 0002, 17 c 8
    2009-02-17, 23:17:16, ff1c, 00ff, ffff 0093 0100, 0000, 0001, d3b3, 0 cd 2, cd 0 6, 0 cd 7, 00bf, 000d, 09eb, 0608, 0000 and 0000, 17 c 8
    2009-02-17, 23:17:19, ff1c, 00ff, ffff 0093 0100, 0000, 0001, d3b4, 0cc9, 0 cd 8, 0 cd 2, 00 c 2, 0009, 09ea, 0608, 0000 and 0000, 17 c 8
    2009-02-17, 23:17:21, ff1c, 00ff, ffff 0093 0100, 0000, 0001, d3b5, 0 cd 2, cd 0 1, 0 cd 1, 00 c 2, 0009, 09e8, 0608, 0000, 0001, 17 c 8

    2009-02-17, 23:17:24, ff1c, 00ff, ffff 0093 0100, 0000, 0001, d3b6, 0 cd 3, cd 0 3, 0 cd 3, 00, 000d, 09eb, 0608, 0001, 0001, 17 c 9
    2009-02-17, 23:17:26, ff1c, 00ff, ffff 0093 0100, 0000, 0001, d3b7, 0ccd, 0 cd 8, 0 cd 4, 00bc, 0006, 09e6, 0608, 0001, 0003, 17 c 8
    2009-02-17, 23:17:29, ff1c, 00ff, ffff 0093 0100, 0000, 0001, d3b8, 0 cd 2, cd 0 3, 0 cd 3, 00C6, 000d, 09e9, 0608, 0001, 0001, 17 c 9
    2009-02-17, 23:17:31, ff1c, 00ff, ffff 0093 0100, 0000, 0001, d3b9, 0ccf, DC 0 3 0 cd 4, 00ba, 000d, 09e8, 0608, 0000 and 0000, 17 c 8
    2009-02-17, 23:17:34, ff1c, 00ff, ffff 0093 0100, 0000, 0001, d3ba 0c1b, 0 cd 3, cd 4 0, 00 c 0, 0009, 09e9, 0607, 0001, 0000, 17 c 8
    2009-02-17, 23:17:36, ff1c, 00ff, ffff 0093 0100, 0000, 0001, d3bb, 0 cd 3, cd 4 0, 0 DC 3, 00 c 2, 000 a, 09e8, 0607, 0001, 0003, 17 c 9
    2009-02-17, 23:17:39, ff1c, 00ff, ffff 0093, 0000, 0100, 0001, d3bc, 0 cd 4 0 DC 4, DC 0-2, 00b 5, 000d, 09e9, 0607, 0001, 0002, 17 c 9
    2009-02-17, 23:17:41, ff1c, 00ff, ffff 0093 0100, 0000, 0001, d3bd, 0cbd, 0 cd 4, 0 DC 7, 00 c 2, 0009, 09e8, 0607, 0001, 0001, 17 c 9

    Text files have no header just the RAW file as seen above.

    Would appreciate any help. Thank you in advance.

    Concerning

    Dan

    Hi Dan,.

    I don't know what version of LabVIEW u using, I have attached the vi in the 8.5 v. My vi sorts the file names by order alphabetical use get info file vi to do sorting like u mentioned

Maybe you are looking for