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 _in.properties
which is unrecognized by Java 17. To resolve this issue, I need to create copies of these resource bundle files that ends with _id.properties
.
Here are solutions for both Linux/macOS
(using Bash).
#!/bin/bash
# Set the root directory for the search
ROOT_DIR="/path/to/root_directory"
# Find all files ending with '_in.properties' and process each one
find "$ROOT_DIR" -type f -name "*_in.properties" | while read -r FILE; do
# Construct file name by replacing '_in.properties' with '_id.properties'
NEW_FILE="${FILE%_in.properties}_id.properties"
# Copy the original file to the new file
cp "$FILE" "$NEW_FILE"
done
Save this script as copy_properties.sh
, make it executable with chmod +x copy_properties.sh
, and run it with ./copy_properties.sh
.
Explanation
find "$ROOT_DIR" -type f -name "*_in.properties"
: Finds all files ending with_in.properties
.while read -r FILE; do ... done
: Loops through each found file.${FILE%_in.properties}_id.properties
: Constructs the new file name by replacing_in.properties
with_id.properties
.cp "$FILE" "$NEW_FILE"
: Copies the original file to the new file.
These scripts will recursively search the specified directory for files ending with _in.properties
, then create a copy of each file with _id.properties
in the same directory.
Latest posts by Wayan (see all)
- How do I get number of each day for a certain month in Java? - September 8, 2024
- How do I get operating system process information using ProcessHandle? - July 22, 2024
- How do I sum a BigDecimal property of a list of objects using Java Stream API? - July 22, 2024