Skip to content

Text Based Find and Replace

The text-based find and replace is case-sensitive and space-sensitive, and while it's the most simple of the actions, it's quite powerful. For this reason it's important to be very precise and target only what's intended. Below are a guide and some examples of use cases for this action.

Step-by-Step Guide

  1. Go to Tools > Advanced Batch Find and Replace.
  2. Filter on the objects that need updates by searching and/or faceting.
  3. Either select all (includes results that appear on additional pages) by toggling Select / deselect all results (all pages, x total) or toggle the buttons for individual objects.
  4. Expand the ► Raw Metadata (JSON) for some of the objects and double-check that the text being searched is only targeting what is intended and that the replacement text makes sense.
  5. Select Text based find and replace Metadata for Archipelago Digital Objects content item from the Action dropdown.
  6. If selecting objects individually, expand the Selected X items and review the list.
  7. Press the Apply to selected items button (don't worry, nothing will happen yet).
  8. Add the values for search (JSON Search String) and replace (JSON Replacement String).
  9. If you're absolutely certain about the replacement, uncheck only simulate and debug affected JSON and Apply.

    only simulate and debug affected JSON

    This option, which is selected by default, will simulate the action and show the list of objects that would be affected, along with the number of modifications for each object and a total number of results processed. For each JSON key and value affected the modifications will count 2:

    1 for the deletion of the current key and value

    +

    1 for the creation of the modified key and value

Use Cases and Examples

Replacing a JSON key

Use Case: A JSON key is currently singular but should be plural.

JSON key example with empty array value
...
"myKey": [],
...
JSON key example with array values
...
"myKey": ["strawberries","blueberries","blackberries"],
...

Follow the steps above and use the following for the search and replace values:

Search Value
"myKey":
Replace Value
"myKeys":

Tip

By using quotes and the colon instead of myKey only, we avoid unintentionally replacing other instances of the text within the JSON.

After applying the changes, we have the following key:

JSON key example with empty array value after update
...
"myKeys": [],
...
JSON key example with array values after update
...
"myKeys": ["strawberries","blueberries","blackberries"],
...

Replacing a JSON value

Use Case: After a batch ingest, it was discovered that JSON values across ADOs in multiple keys contain the same typo: Agnes Meyerhoff (two fs) instead of Agnes Meyerhof.

JSON value example with typo
...
"creator_lod": [
    {
        "name_uri": "",
        "role_uri": "http:\/\/id.loc.gov\/vocabulary\/relators\/art",
        "agent_type": "personal",
        "name_label": "Meyerhoff, Agnes",
        "role_label": "Artist"
    },
    {
        "name_uri": "",
        "role_uri": "http:\/\/id.loc.gov\/vocabulary\/relators\/col",
        "agent_type": "personal",
        "name_label": "Messenger, Maria, , 1849-1937",
        "role_label": "Collector"
    }
],
"description": "Inscription on mount: \"Meyerhoff, Agnes \\ Frankfurt - a\/M. \\ Inv el-lith \\ Painter.\" Inscription on verso: \"Agnes Meyerhoff \\ Frankfurt a\/M \\ inv. [at?] lith. \\ [maker in?]\".",
...

Follow the steps above and use the following for the search and replace values:

Search Value
Meyerhoff, Agnes
Replace Value
Meyerhof, Agnes

After applying the changes, we have the following values:

JSON values after update
...
"creator_lod": [
    {
        "name_uri": "",
        "role_uri": "http:\/\/id.loc.gov\/vocabulary\/relators\/art",
        "agent_type": "personal",
        "name_label": "Meyerhof, Agnes",
        "role_label": "Artist"
    },
    {
        "name_uri": "",
        "role_uri": "http:\/\/id.loc.gov\/vocabulary\/relators\/col",
        "agent_type": "personal",
        "name_label": "Messenger, Maria, , 1849-1937",
        "role_label": "Collector"
    }
],
"description": "Inscription on mount: \"Meyerhof, Agnes \\ Frankfurt - a\/M. \\ Inv el-lith \\ Painter.\" Inscription on verso: \"Agnes Meyerhoff \\ Frankfurt a\/M \\ inv. [at?] lith. \\ [maker in?]\".",
...

Replacing a JSON value with escape characters

Use Case: The URL for a website that appears in multiple keys needs to be updated from http://hubblesite.org to https://hubblesite.org.

JSON value example with URL after update
...
"rights": "This digital image may be used for educational or scholarly purposes without restriction. Commercial and other uses of the item are prohibited without prior written permission from the NASA and the Space Telescope Science Institute (STScI). For more information, please visit the NASA and the Space Telescope Science Institute's Copyright web page at [http:\/\/hubblesite.org\/copyright](http:\/\/hubblesite.org\/copyright).",
...
"description": "\"The largest NASA Hubble Space Telescope image ever assembled, this sweeping bird’s-eye view of a portion of the Andromeda galaxy (M31) is the sharpest large composite image ever taken of our galactic next-door neighbor. Though the galaxy is over 2 million light-years away, The Hubble Space Telescope is powerful enough to resolve individual stars in a 61,000-light-year-long stretch of the galaxy’s pancake-shaped disk. ... The panorama is the product of the Panchromatic Hubble Andromeda Treasury (PHAT) program. Images were obtained from viewing the galaxy in near-ultraviolet, visible, and near-infrared wavelengths, using the Advanced Camera for Surveys and the Wide Field Camera 3 aboard Hubble. This cropped view shows a 48,000-light-year-long stretch of the galaxy in its natural visible-light color, as photographed with Hubble's Advanced Camera for Surveys in red and blue filters July 2010 through October 2013.\" -full description available at: [http:\/\/hubblesite.org\/image\/3476\/gallery\/73-phat](http:\/\/hubblesite.org\/image\/3476\/gallery\/73-phat).",
...

Follow the steps above and use the following for the search and replace values:

Search Value
http://hubblesite.org
Replace Value
https://hubblesite.org

Note

You'll notice that the escape characters for the forward slash (\/), which appear in the raw JSON, do not need to be included in the search or replace values.

After applying the changes, we have the following values:

JSON value example with URL after update
...
"rights": "This digital image may be used for educational or scholarly purposes without restriction. Commercial and other uses of the item are prohibited without prior written permission from the NASA and the Space Telescope Science Institute (STScI). For more information, please visit the NASA and the Space Telescope Science Institute's Copyright web page at [https:\/\/hubblesite.org\/copyright](https:\/\/hubblesite.org\/copyright).",
...
"description": "\"The largest NASA Hubble Space Telescope image ever assembled, this sweeping bird’s-eye view of a portion of the Andromeda galaxy (M31) is the sharpest large composite image ever taken of our galactic next-door neighbor. Though the galaxy is over 2 million light-years away, The Hubble Space Telescope is powerful enough to resolve individual stars in a 61,000-light-year-long stretch of the galaxy’s pancake-shaped disk. ... The panorama is the product of the Panchromatic Hubble Andromeda Treasury (PHAT) program. Images were obtained from viewing the galaxy in near-ultraviolet, visible, and near-infrared wavelengths, using the Advanced Camera for Surveys and the Wide Field Camera 3 aboard Hubble. This cropped view shows a 48,000-light-year-long stretch of the galaxy in its natural visible-light color, as photographed with Hubble's Advanced Camera for Surveys in red and blue filters July 2010 through October 2013.\" -full description available at: [https:\/\/hubblesite.org\/image\/3476\/gallery\/73-phat](https:\/\/hubblesite.org\/image\/3476\/gallery\/73-phat).",
...

Thank you for reading! Please contact us on our Archipelago Commons Google Group with any questions or feedback.

Return to the main Find and Replace documentation page or the Archipelago Documentation main page.


Last update: December 13, 2022
Created: December 13, 2022