Skip to content

Instantly share code, notes, and snippets.

@msoutopico
Created October 30, 2023 23:56
Show Gist options
  • Save msoutopico/72cee9a221860fedb9f876372ffc8e80 to your computer and use it in GitHub Desktop.
Save msoutopico/72cee9a221860fedb9f876372ffc8e80 to your computer and use it in GitHub Desktop.
add_file_to_batch.sh
#!/usr/bin/env bash
source_dir="/home/souto/Repos/ACER-PISA-2025-FT/pisa_2025ft_translation_common/source"
root="$source_dir/batch1"
config="$source_dir/files.yaml"
# cd $root
batches="$(yq -r 'keys | .[]' $config)"
for filepath in $(find $root -type f -name "*.xml")
do
# echo "### $filepath ###"
filename="$(basename -- $filepath)"
batch=$(FILE=$filename yq '.. | select(. == env(FILE)) | parent | key' $config)
# [[ "$batch" == "04_QQS_N" ]] && echo "$batch: $filename"
# if [[ "$batches" == *"$batch"* ]] && [[ "$batch" != "" ]]; then
if [[ ${batches[@]} =~ $batch ]] && [[ "$batch" != "" ]]; then
echo "$batch;$filename"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment