#!/bin/bash

#build this: https://github.com/darkwater/steam-clip-exporter
EXTRACT_PATH=~/git/steam-clip-exporter/target/debug/steam-clip-exporter
set -e

for dir in clip_*; do
    file="$dir/output.mp4"
    if [[ ! -f "$file" ]]; then
        echo Extracting "$dir"
        "$EXTRACT_PATH" "$dir"
    fi
    
    if [[ -f "$file" ]]; then
        echo Moving "$dir/output.mp4" 
        mv "$dir/output.mp4" "../exports/$dir.mp4" \
            && rm -r "$dir" \
            || echo "$dir: error"
    fi
done
