#!/bin/sh

folder=$PWD
for entry in "$folder"/*
do
  #echo "Processing: $entry"
  file_name=$(basename $entry)
  FILE="$entry"/qualfile.tsv
  if [ -f "$FILE" ]; then
    #Check the file has not been sorted already 
		sorted_f="$entry"/qualfile_sorted.tsv
    if  [ ! -f "$sorted_f" ]; then
        touch "$sorted_f"
				echo "Sorting $FILE "
        kgtk sort -i "$FILE" -c 'id' -o "$sorted_f"
    fi
  fi
  #cp "$entry"/modified_prop_count.tsv "$target"/"$file_name"_modified_prop_count.tsv
done
