Highlighted

Any way to globally update cross references to another file?

Community Beginner ,
Apr 09, 2020

Copy link to clipboard

Copied

I have a book that includes about fifty chapters. In each of those chapters, there are numerous cross references to a file named UM6411, which is not a file in the book. We are in the process of creating a new document set using the all the files from the old book, but the file previously named UM6411 needs to be changed to UM7411. Of course, this breaks all of the cross references to UM6411 in all of those fifty chapters. Is there a way to globally change the source document for the cross references from UM6411 to UM7411? The content for now is identical, so the headings that the cross reference link to in UM6411 are all intact in UM7411.

 

I know this can be done through a tedious process of saving each file in the book to MIF, then searching and replacing UM6411 with UM7411 in Notepad. However, as I mentioned, there are at least fifty files in this book, and there will be a need to do this in several other equally large book files. 

Correct answer by tom_dirks | Community Beginner

Thank you for your help. I have come up with a fairly good way to do this. I have a script from FrameScript to convert a book file to mif format. I can then run a search and replace for multiple files in Notepad++ that replaces all instances of UM6411 with UM6711 in every mif file in the folders where the converted mif files are located. The filter option in Notepad++ allows me to just look for *.mif files. After that, I just need to open each mif file and save back to FrameMaker format (I'm sure a script would be fairly easy to come up with rather than opening them individually as I did). Thanks to everyone for their help.

Views

760

Likes

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

Any way to globally update cross references to another file?

Community Beginner ,
Apr 09, 2020

Copy link to clipboard

Copied

I have a book that includes about fifty chapters. In each of those chapters, there are numerous cross references to a file named UM6411, which is not a file in the book. We are in the process of creating a new document set using the all the files from the old book, but the file previously named UM6411 needs to be changed to UM7411. Of course, this breaks all of the cross references to UM6411 in all of those fifty chapters. Is there a way to globally change the source document for the cross references from UM6411 to UM7411? The content for now is identical, so the headings that the cross reference link to in UM6411 are all intact in UM7411.

 

I know this can be done through a tedious process of saving each file in the book to MIF, then searching and replacing UM6411 with UM7411 in Notepad. However, as I mentioned, there are at least fifty files in this book, and there will be a need to do this in several other equally large book files. 

Correct answer by tom_dirks | Community Beginner

Thank you for your help. I have come up with a fairly good way to do this. I have a script from FrameScript to convert a book file to mif format. I can then run a search and replace for multiple files in Notepad++ that replaces all instances of UM6411 with UM6711 in every mif file in the folders where the converted mif files are located. The filter option in Notepad++ allows me to just look for *.mif files. After that, I just need to open each mif file and save back to FrameMaker format (I'm sure a script would be fairly easy to come up with rather than opening them individually as I did). Thanks to everyone for their help.

Views

761

Likes

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
Apr 09, 2020 0
Community Beginner ,
Apr 09, 2020

Copy link to clipboard

Copied

So these are clickable crossreferences and rely on the fact that the end user has access to a particular server or webpage where UM7411 resides?

Kind regards,

Mats

Likes

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
Reply
Loading...
Apr 09, 2020 0
Community Beginner ,
Apr 09, 2020

Copy link to clipboard

Copied

All of the FrameMaker files are converted to pdf, so the end user clicks the links in a pdf of the book file to open a pdf file for UM6711.

Likes

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
Reply
Loading...
Apr 09, 2020 0
Mentor ,
Apr 09, 2020

Copy link to clipboard

Copied

Hi Tom,

 

This is a classic case for scripting. Sometimes a script might take longer to develop than just doing the task manually, but I don't think so in this case, because the script can be very short and simple.

 

Have you ever used ExtendScript? Here is a sample script that I think will do what you want, a single file at a time. It could be extended to do a whole book automatically, but that is more complicated and might be more work than just running it file by file.

 

replaceXrefFilenames(app.ActiveDoc, "UM6411", "UM7411");

function replaceXrefFilenames(doc, oldFilename, newFilename)
{
  var count = 0;
  var xref = doc.FirstXRefInDoc;
  while(xref.ObjectValid())
  {
    var filename = xref.XRefFile;
    if(filename.indexOf(oldFilename) > -1)
    {
      xref.XRefFile = filename.replace(oldFilename, newFilename);
      count++;
    }
    xref = xref.NextXRefInDoc;
  }
  alert("Done. " + count + " xref(s) adjusted.");
}

 

If you are totally new to this, here are basic instructions:

 

- Select File > Script > New Script

- Paste that code in the empty script file that appears

- Make the desired FM file active in the FrameMaker window

- Select Debug > Run or just click the run button (green arrow)

 

The very first line of the script is the function call that can be adjusted to replace whatever string. It is currently case-sensitive... a little more code could be added for case insensitivity. Note that when the script analyzes target filename, it is looking at the fully-qualified path. So you could also use this script to change the folder of target files too.

 

The script doesn't save anything, so it should be no risk to try. Disclaimer... if it melts down your CPU, I will tell your lawyers that I live in a refrigerator box in the woods.

 

Hope this helps,

Russ

Likes

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
Reply
Loading...
Apr 09, 2020 1
Community Beginner ,
Apr 09, 2020

Copy link to clipboard

Copied

Thank you for your help. I have come up with a fairly good way to do this. I have a script from FrameScript to convert a book file to mif format. I can then run a search and replace for multiple files in Notepad++ that replaces all instances of UM6411 with UM6711 in every mif file in the folders where the converted mif files are located. The filter option in Notepad++ allows me to just look for *.mif files. After that, I just need to open each mif file and save back to FrameMaker format (I'm sure a script would be fairly easy to come up with rather than opening them individually as I did). Thanks to everyone for their help.

Likes

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
Reply
Loading...
Apr 09, 2020 1
Adobe Community Professional ,
Apr 09, 2020

Copy link to clipboard

Copied

Hi Tom, I have a script that will allow you to do this via a spreadsheet. It is called PathChanger. See my store at frameexpert dot com. Thanks. -Rick

Likes

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
Reply
Loading...
Apr 09, 2020 0
Community Beginner ,
Apr 09, 2020

Copy link to clipboard

Copied

I will check that out. Thanks.

Likes

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
Reply
Loading...
Apr 09, 2020 0