<commit_before>#!/usr/bin/env bash

PATH_IN=/RecordedData/Tmpfs
PATH_OUT=/RecordedData/Images

cd "$PATH_IN"

while true
do
    sleep 5
    rsync -ru . "$PATH_OUT"
    count=$(ls -d */ 2>/dev/null | wc -l)
    if [ $count -gt 1 ] ; then
        rm -rf "$(ls -d */ | head -1)"
    fi;
done<commit_msg>Improved sync.sh<commit_after>#!/usr/bin/env bash

PATH_IN=/RecordedData/Tmpfs
PATH_OUT=/RecordedData/Images
RECORDER_BIN=v4l2-ctl

cd "$PATH_IN"

while true
do
    sleep 5
    rsync -ru . "$PATH_OUT"
    pgrep "$RECORDER_BIN" > /dev/null 2>&1
    if [ $? -eq 0 ] ; then
        # if recorder is working - remove all except for the last
        rm -rf $(ls -r -d */ 2>/dev/null | tail -n +2)
    else
        #otherwise, remove all
        rm -rf *
    fi;
done
{'fraction_non_alphanumeric': 0.14586070959264127, 'fraction_numerical': 0.01576872536136662, 'mean_word_length': 2.2703862660944205, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7519043', 'n_tokens_mistral': 316, 'n_tokens_neox': 296, 'n_words': 82}