How to replace text on confluence

Rahul Aich [Nagra]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 4, 2014

Hi All

In my confluence 4.3, i have lot of users hardcoding links to the attachments (instead of using the attachment macro)  that are uploaded on confluence.

The problem with this is that if i change my confluence URL then all these hardcoded links will break.

What are my options to not let the links break?

  • Can i do a find and replace for all such hardcoded links to attachments.
  • Do i have to update hundreds to pages manually?
  • Can i do it via database? any plugins?

Rahul

 

3 answers

1 vote
Stephen Gurnick
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 5, 2014

Another option for changing the base URL is to do the following:

  1. Use your database back-up tools (e.g. if you use MySQL, then mysqldump) to create a dump of your Confluence database. This creates a plain text file containing the SQL to rebuild the database
  2. Use the sed command on this file to change your URLs from the old to the new. For example:

    # sed -i "s/OLD-URL/NEW-URL/g" DATABASE_SQLDUMP_FILE
  3. Restore your database file

As with anything involving the database, make sure you perform a back-up that you will leave unchanged that you can restore if something goes wrong. Also, first try this out within a test environment.

From my experience though - this procedure has worked well for me and avoided having to install add-ons.

1 vote
rrudnicki
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 5, 2014

Hi Aich, 

I found this answer that seems very similar with this question. I think worth it to try. However, it is a third part plugin, so you need to install it. The plugin can be found in this link.

After you have installed the plugin, you can try this command line:

confluence --action runFromContentList --runFromPageList "\"https://confluence.in.here.com\"" --space NAME-OF-A-SPACE --common "--action modifyPage --id @pageId@ --findReplace \"https://wiki.ad.navteq.com/confluence#https://confluence.in.here.com\" --special \" #\" "

 

I hope it helps.

Regards, 

Renato Rudnicki

 

0 votes
Jonathan Simonoff
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 5, 2014

An option I've used for this kind of thing is to write an external script (I use Python and XML/RPC) that reads pages, finds and changes the text, and saves the pages back.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events