#!/bin/bash

# Ripeti le operazioni per la cartella test e il file test_COVIDx9A.txt
mkdir -p COVIDx-splitted-resized-112/test
cd COVIDx-splitted-resized-112/test
mkdir -p pneumonia COVID-19 normal
cd ../..

COUNTER=0

while read line; do
  index=$(echo $line | awk '{print $1}')
  filename=$(echo $line | awk '{print $2}')
  class=$(echo $line | awk '{print $3}')

  cp -n COVIDx/test/$filename COVIDx-splitted-resized-112/test/$class/$filename

  echo "$COUNTER"
  COUNTER=$((COUNTER+1))

done < COVIDx/test_COVIDx9A.txt

echo "" > COVIDx-splitted-resized-112/test_COVIDx9A.txt
while read line; do
  index=$(echo $line | awk '{print $1}')
  filename=$(echo $line | awk '{print $2}')
  class=$(echo $line | awk '{print $3}')
  other=$(echo $line | awk '{print $4}')

  echo "$index $class/$filename $class $other" >> COVIDx-splitted-resized-112/test_COVIDx9A.txt
done < COVIDx/test_COVIDx9A.txt