#!/bin/bash

read_dir () {
	echo "{ name = \"`basename "$1"`\"; children = ("
	for file in "$1"/*; do
		if [[ -f $file ]]; then
			echo "{filename = \"$file\"; },"
		elif [[ -d $file ]]; then
			read_dir "$file"
		fi
	done
	echo '); },'
}

echo '{ documents = ('
read_dir "$1"
echo '); }'
