Search and replace tool: Difference between revisions

From MoodleDocs

(Additional tools may be found elsewhere in the admin settings)

No edit summary
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 10: Line 10:


Options:
Options:
--search=STRING      String to search for.
--search=STRING      String to search for.
--replace=STRING      String to replace with.
--replace=STRING      String to replace with.
--shorten            Shorten result if necessary.
--shorten            Shorten result if necessary.
--non-interactive    Perform the replacement without confirming.
--non-interactive    Perform the replacement without confirming.
-h, --help            Print out this help.
-h, --help            Print out this help.
Example:
cd /path/to/your/moodle/dir
php admin/tool/replace/cli/replace.php --search=//oldsitehost --replace=//newsitehost --shorten --non-interactive


==See also==
==See also==
Line 23: Line 32:
[[fr: Recherche et remplacement]]
[[fr: Recherche et remplacement]]
[[de:Datenbank-Suche]]
[[de:Datenbank-Suche]]
[[ja:検索および置換ツール]]

Latest revision as of 03:58, 28 October 2024

Admins can search and replace text e.g. URLs in their Moodle database using the search and replace tool at http://yourmoodlesite.org/admin/tool/replace/index.php (replacing yourmoodlesite.org with the address of your Moodle site). This is useful when a Moodle site is moved from one server to another or when the URL changes.

Alternatively, a command line script can be used to search and replace text. See Administration via command line for details.

Warning: A database and site backup should be created before performing a search and replace.


CLI Parameters

The following parameters can be utilized with the Search and Replace cli sript.

Options:

--search=STRING String to search for.

--replace=STRING String to replace with.

--shorten Shorten result if necessary.

--non-interactive Perform the replacement without confirming.

-h, --help Print out this help.

Example:

cd /path/to/your/moodle/dir
php admin/tool/replace/cli/replace.php --search=//oldsitehost --replace=//newsitehost --shorten --non-interactive

See also

  • Tracker issue MDL-35099 Convert hidden search/replace script into a proper core admin tool