• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Find and Replace Operations on .dita files

Explorer ,
Mar 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

Hi All,

I am new to scripting.

But I would have dita maps that point to an absolute destination for each of the xml and dita files and I would like to change these to relative addressing.

I figure that a script might be the right way to do this.

Any alternate suggestions are welcome.

Appreciate it,

Myko

TOPICS
Scripting

Views

415

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Mar 16, 2018 Mar 16, 2018

Thanks Jang,

I have to confess that since I put this question in writing I remembered that I had "GrepWin" on my pc and when I tried it it was able to find and replace the text in all the dita files in the present folder and sub-folders in one go. Now I can port it to my local drive and operate without any trouble... as yet.

Myko

Votes

Translate

Translate
Advocate ,
Mar 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

Hello Myko,

If you have DITA maps you should look into XSLT. That will be much easier than scripting. You could even load the map in FrameMaker XML view and do a search and replace there if the pattern you are replacing is easy enough. In the XML view you can also run an XSLT.

Jang

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

Thanks Jang,

I have to confess that since I put this question in writing I remembered that I had "GrepWin" on my pc and when I tried it it was able to find and replace the text in all the dita files in the present folder and sub-folders in one go. Now I can port it to my local drive and operate without any trouble... as yet.

Myko

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 16, 2018 Mar 16, 2018

Copy link to clipboard

Copied

ExtendScript has a File object and Regular Expressions so you could do this within FrameMaker as well if it is more convenient.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 19, 2018 Mar 19, 2018

Copy link to clipboard

Copied

Hi Frameexpert,

I do remember that you and I had a conversation where you said we could make a a script for this function. I would still like to learn how to do that. If it is simple enough would you be willing to post it here?

Thanks,

Mike

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 19, 2018 Mar 19, 2018

Copy link to clipboard

Copied

LATEST

Hi Mike, I am busy with production work so I can't do this for free. I would suggest that you look at the documentation (Help > JavaScript Tools Guide CC) and look at the File System Access chapter. Basically, you want to read the file into a string and then apply the regular expression to update the paths. Then you write the string back to the file. -Rick

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines