This is a Moodle plugin that allows administrators to search and replace strings in the Moodle database.
It is conceptually similar to the replace tool in core, but way more powerful as it can search and replace strings in tables and columns of the Moodle database, as well as inside files withing the File API, including files inside zip files such as H5P.
They can use simple text search or regular expressions, and the found records can be downloaded as csv and the per-record replacements uploaded as a new csv giving very fine grained replacement capability.
The plugin does not store any personal data.
Moodle version | Branch | PHP |
---|---|---|
Moodle 4.1+ | MOODLE_401_STABLE |
7.4+ |
-
Install the plugin the same as any standard Moodle plugin, you can use git to clone it into your source:
git clone [email protected]:catalyst/moodle-tool_advancedreplace.git admin/tool/advancedreplace
Find all occurrences of "http://example.com/" followed by any number of digits on tables:
cd admin/tool/advancedreplace/cli/
php find.php --regex-match="http://example.com/\d+" --output=result.csv
Find all occurrences of "http://example.com/" in a table:
php find.php --regex-match="http://example.com/\d+" --tables=page --output=result.csv
Find all occurrences of "http://example.com/" in multiple tables:
php find.php --regex-match="http://example.com/\d+" --tables=page,forum --output=result.csv
Find all occurrences of "http://example.com/" in different tables and columns:
php find.php --regex-match="http://example.com/\d+" --tables=page:content,forum:message --output=result.csv
Find all occurrences of "http://example.com/" in all tables except the ones specified:
php find.php --regex-match="http://example.com/\d+" --skip-tables=page,forum --output=result.csv
Find all occurrences of "http://example.com/" in all columns except the ones specified:
php find.php --regex-match="http://example.com/\d+" --tables=page --skip-columns=intro,display --output=result.csv
If you have issues please log them in GitHub.
Please note our time is limited, so if you need urgent support or want to sponsor a new feature then please contact Catalyst IT Australia.
This plugin was developed by Catalyst IT Australia.