Is there a way to batch search and replace within Confluence?
I have found an abandoned plugin which does this, but it does not support Confluence 3.4+
Is there a way to do this through webDav maybe? My attempts have failed at the point of accessing the Network Place for Confluence through various batch editors - all of which don't seem to be able to pickup the files in Confluence.
Any ideas / solutions would be appreciated.
Thanks - Mick
Hi Mick
I've not used CLI before and I'm sure that will service all your needs, however more of an FYI. This weekend i sucessfully used Jeans's resolve in a similiar question i posted. See: https://answers.atlassian.com/questions/12526/confluence-wiki-markup-search-and-replace. this uses a plugin and regex queries. I sucessfully ran this against a confluence 3.5.11 instance to change wide range of user macros before upgrading to 4.0.
Gavin.
Gavin,
Thanks for the suggestion.
I looked at that plugin as a starting point but then steered clear simply because it was a bit hacky. With confirmation from you that you have successfully used it and everything is going well, I think I will give this a go on a trial basis to see if it will successfully work for me also.
Do you have any tips / tricks of things to try and avoid or suggested operations to make it easy to use?
I will be installing today, so hopefully I have it all worked out by this time tomorrow.
Thanks again. Mick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mick
yeah I know what you mean about being a bit of a hack - i had exactly the same concerns. below is my my advice /experience when used against confluence 3.5.11 running on Ubuntu 10.4 LTS.
global-search-replace-plugin-1.2.1.jar into confluence
$ mkdir ~/META-INF $ mkdir ~/META-INF/lib $ mv backport-util-concurrent-3.1.jar ~/META-INF/lib/ $ jar uf global-search-replace-plugin-1.2.1.jar META-INF/lib/backport-util-concurrent-3.1.jar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Gavin.
I am having some difficulties installing the plugin at the moment, but once I have it up and running, I will definitely be following your advice.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well the plugin is installed, but it's not working for us.
We are getting a "page not found" error when we navigate to the /plugins/servlet/searchReplace page.
It's not obvious what is causing the problem, all permissions look good and the plugin shows up as functional. Oh well. Luckily I have Bob's suggestion to fall back on - I'll be testing this today so fingers crossed it all works out.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mick
that's a shame you cannot get this to work. I will use the email address you posted earlier (in Bob's thread) and attach the plugin jar file (with the back port embeded) that I uploaded and used against confluence 3.5.11. I'll do this in the next couple of hours once I'm at work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The modified plugin from Gavin worked a treat.
Thanks for all the help Gavin!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can FIND and REPLACE multiple words in Multiple doc & docx files using simple software
http://www.technocomsolutions.com/advancefindreplacehelp.htm
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can use Confluence Command Line Interface to script getPageSource and storePage after doing search and replace. If your use case is simple enough, you can use findReplace parameter on the storePage to do the replacement.
Example scripts are https://bitbucket.org/bob_swift/confluence-cli/src/tip/src/main/resources/examples/replace.sql and https://bitbucket.org/bob_swift/confluence-cli/src/tip/src/main/resources/examples/replace.txt
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Bob. I have installed Confluence CLI and have just starting to play around with it.
The documentation is really good btw - great job!
Ideally, I would like to search and replace on all descendents under a specified page. If I wanted to replace the word HELP with Get Support could I do something like this?
confluence --action storePage --space "space name" --title "page name" --descendents --findReplace "Help:Get Support"
I have tried this out and it reports back successfully, but the page itself doesn't update. Does this script look right to you?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Bob,
I have made some progress and have two command line scripts working.
Add page contents to output file:
confluence --action getPageSource --space "Space Name" --title "Page Name" --file out.txt
Replace page with itself and run findReplace
confluence --action storePage --space "Space Name" --title "Page Name" --file out.txt --findReplace "Help:Get Support"
This is all working nicely. Now I am trying to insert these two command line scripts into a script file which will work through each page outputting its contents, then updating its contents and running --findReplace.
Is this the right direction do you think for a batch change?
Are there any examples of run scripts for Confluence CLI available?
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think you are on the right path. Here is an example I can add. You should be very careful to test this and consider using --simulate support and or limit your query to a test space. One key is to make sure your query only selects pages that have your replacement string so that only those pages get a new version with the updated text.
I can't add this as an attachment, so it might get messed up
# Run using something like
# confluence --action runFromSql --file src/main/resources/examples/replace.sql --database confluence-3.5.0 --host imac.local --driver postgresql
#
# where replace.txt looks something like:
# --action getPageSource --space @space@ --title "@title@" --file out.txt
# --action storePage --space @space@ --title "@title@" --file out.txt --findReplace "Help:Get Support"
#
select
'run' as action,
'src/main/resources/examples/replace.txt' as file,
'@space@:' || s.spacekey || ',@title@:' || c.title as "findReplace"
from content as c, bodycontent as b, spaces as s
where
c.contentid = b.contentid
and s.spaceid = c.spaceid
and c.content_status = 'current'
and c.contentid = b.contentid
and b.body like '%Help%'
and c.contentid is not null
and c.spaceid is not null
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just saw your first comment now. descendents is not valid for getting and storing pages. However, if you adjust the query you can subset it to all descendents of a specific page using parentid etc....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Bob.
Would you mind emailing me the attachment ... mroff@hemispheregps.com
I am not sure I exactly follow yet, I will give it a go on a limited basis and see if I can get it to work.
It is obvious that the CLI is very powerful once you get it working and know how to command it. I am not sure I am there yet :(
Thanks for all the advice.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I submitted the scripts and added links to them in the main answer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oops, I missed that - thanks Bob.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I got the scripts to work, but hit a snag. I am trying to replace a fairly complicated macro which includes multiple variables etc. The text includes such characters as , % : and in turn this confuses the scripting.
Likewise the replacement text also includes complicated text which includes , $ :
From the experiments I did, there isn't a way to replace text that includes these special characters due to the way the scripting works. Is that right Bob?
Is there a way to specify "This is the: exact text; that I want $$ to replace%?"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.