#!/bin/sh # convert statuses as files and dirs json="$(cat)" ids=$(echo "$json" | jj -l '#.id' | sed 's/"//g') mkdir -p "$main_basedir/all_statuses/$instance" mkdir -p "$main_basedir/statuses/$instance" for i in $ids; do if [ -f "$main_basedir"/all_statuses/$instance/$i/$i.json ]; then ids=$(echo "$ids" | sed -E "s/.?$i.?//g") continue elif [ -d "$main_basedir"/all_statuses/$instance/*/$i ]; then ids=$(echo "$ids" | sed -E "s/.?$i.?//g") continue fi status_date=$(echo "$json" | jj "#[id=$1].created_at") mkdir -m 711 -p "$main_basedir"/all_statuses/$instance/$i touch -d "$status_date" "$main_basedir"/all_statuses/$instance/$i echo "$json" | jj -p "#[id=$i]" > "$main_basedir"/all_statuses/$instance/$i/$i.json done export ids echo "$json" | "$main_basedir"/utils/extract_fields_statuses.sh