How to replace text on confluence

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

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

 

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.

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

849 views 23 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you