unixrecursionrename

batch rename 20,000 files. remove set # of characters from the end recursively


I am struggling with the recursive part

Im on UNIX systems, but can use a windows VM if necessary. I have 20,000 files in 3 deep nested folders that all have "supplemental-metadata" at the end. example:

IMG_4955.JPG.supplemental-metadata.json

I need the supplemental-metadata gone from all 20,000.

I can use the rename tool and do rename 's/\.supplemental-metadata\././' *json and that does it to the current directory but i need it recursively. I search for how to do it with find but am stuck on how to use it. Any help for this what i feel like is a simple issue.


Solution

  • Using find:

    find . -name '*.supplemental-metadata.json' -exec rename 's/\.supplemental-metadata\././' {} \;