[pmwiki-users] modifying wikish renaming pages/groups scripts to update links with spaces
Peter Bowers
pbowers at pobox.com
Fri Jul 20 09:46:08 CDT 2012
On Fri, Jul 20, 2012 at 4:28 PM, Alex Eftimiades
<alexeftimiades at gmail.com> wrote:
> Yes. An example might be:
> [[Group With Spaces/Page With Spaces]]
I'm afraid there's no nice, neat, elegant way to do this. And the
spaces would have to be exact in order for it to work. But something
like this would move you in the right direction:
===(snip)===
//Rename Page
set -s OldGroup = "Group With Spaces"
set -s OldGroupPN = "GroupWithSpaces"
set -s OldPage = "Page With Spaces"
set -s OldPagePN = "PageWithSpaces"
set -s NewGroup = "New Group With Spaces"
set -s NewGroupPN = "NewGroupWithSpaces"
set -s NewPage = "New Page With Spaces"
set -s NewPagePN = "NewPageWithSpaces"
sed -i 's|${OldGroup}([./]\)?)${OldPage}|${NewGroup}$1${NewPage}|gi'
`pagelist link=${OldGroupPN}.${OldPagePN} sep=\n`
mv ${OldGroupPN}.${OldPagePN} ${NewGroupPN}.${NewPagePN}
===(snip)===
If you were going to be doing this often then it might be worthwhile
scripting the initialization of the PN variables using sed, but
probably that won't happen too often.
I suppose you could use "Group *With *Spaces" and "Page *With *Spaces"
(note the addition of an asterisk after each space) to come up with a
more generalized approach. (This would make the automated
initialization of the PN variables more difficult, but I'm leaving
that "out of scope" right now.)
I haven't actually tried this, so there may be some minor debugging
you would need to do...
-Peter
More information about the pmwiki-users
mailing list