# Given a directory containing multiple clams workspaces, call ls_datasets on the
# latest iteration.

set -eou pipefail

FILE=$1
if ! [[ -d $FILE ]]; then exit 5; fi

for WORKSPACE in `ls -tr $FILE`
do
    ITERATION="$(ls $FILE/$WORKSPACE | tail -1)"
    /usr/bin/bazel-run.sh //mapping/distributed_mapping/scripts:ls_datasets -- $FILE/$WORKSPACE/$ITERATION/aligned_datasets.pb --format chum_range
    echo $WORKSPACE;
done
