#!/bin/sh

echo "Compressing KGTK dumps in bz2..."

folder=.
for entry in "$folder"/*
do
	prev="$entry"/edgefile_sorted.tsv
  if [ -f "$prev" ]; then
		folder_new_name=$(basename "$entry").tar.bz2
		echo "Dealing with KGTK dump $entry"
		#Check if the file is already being compressed
		if ! [ -f $folder_new_name ]; then
			if ! [ -f "kgtk_compressed_dumps/$folder_new_name" ]; then
				echo "Creating $folder_new_name ..."
				tar -cjvf $folder_new_name $entry
				mv $folder_new_name kgtk_compressed_dumps
			else
				echo "Dump already compressed. Skipping"
			fi
		fi
	fi
done


