Last active
December 15, 2023 14:54
-
-
Save msoutopico/4bbe0ac90b71f709a4f5d8fc3bdf91c1 to your computer and use it in GitHub Desktop.
move_target_files_to_final_repo.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# run this script as: | |
# bash move_target_files_to_final_repo.sh -i /path/to/project -o /path/to/final/repo | |
# e.g. | |
# bash move_target_files_to_final_repo.sh -i /home/souto/Repos/ACER-PISA-2025-FT/pisa_2025ft_translation_it-IT_trend-prepare-files -o /home/souto/Repos/ACER-PISA-2025-FT/pisa_2025ft_translation_final | |
# flag -i/--input: $1 | |
project_path="$2" | |
# flag -o/--output: $3 | |
final_repo_path="$4" | |
# etc | |
echo "Go to the project folder ${project_path}" | |
cd "$project_path" | |
echo "Sync project" | |
git pull --rebase | |
echo "Delete the final folder if it exits" | |
[ -d final ] && rm -r final | |
echo "Make a copy of the target folder and cd into it" | |
cp -r target final | |
cd final | |
echo "Flatten file structure" | |
find . -type f -exec mv {} . \; | |
# echo "Remove directories" | |
# find * -type d -exec rmdir {} + | |
echo "Remove the dummy locale suffix" | |
locale=$(echo "$project_path"| cut -d'_' -f 4) | |
echo "locale: $locale" | |
rename "s/_$locale//" *.xml | |
echo "Move all files to the final repo" | |
mkdir -p "${final_repo_path}/translations/$locale/batch1" | |
find $project_path/final -type f -name "*.xml" -exec mv {} "${final_repo_path}/translations/$locale/batch1" \; | |
# ~/Repos/ACER-PISA-2025-FT/pisa_2025ft_translation_final/translations/pb/batch1/ | |
echo "Remove the final folder" | |
cd .. && rm -r final | |
echo "Push changes" | |
cd "$final_repo_path" | |
git pull --rebase | |
git add . | |
git commit -m "Updated target files for $locale" | |
git push |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment