How to copy files ending with a specific string to another file in Linux/macOS?

In Java 17, the Locale for Indonesia changed from in_ID to id_ID. In my project, the resource bundle files are named with the suffix which is unrecognized by Java 17. To resolve this issue, I need to create copies of these resource bundle files that ends with

Here are solutions for both Linux/macOS (using Bash).


# Set the root directory for the search

# Find all files ending with '' and process each one
find "$ROOT_DIR" -type f -name "*" | while read -r FILE; do
    # Construct file name by replacing '' with ''
    # Copy the original file to the new file
    cp "$FILE" "$NEW_FILE"

Save this script as, make it executable with chmod +x, and run it with ./


  • find "$ROOT_DIR" -type f -name "*": Finds all files ending with
  • while read -r FILE; do ... done: Loops through each found file.
  • ${} Constructs the new file name by replacing with
  • cp "$FILE" "$NEW_FILE": Copies the original file to the new file.

These scripts will recursively search the specified directory for files ending with, then create a copy of each file with in the same directory.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.