#!/bin/bash
#
origem=$(pwd)
#
IFS=$(echo -en "\n\b")
#
shopt -s dotglob  # Enable hidden files in wildcards
#
find -L "$origem" -type d,l -exec bash -c 'dir="$1"; \
      echo "Processando o Diretorio.: $dir";cd "$dir/"; \
      tree -H . -L 1 --noreport --dirsfirst -T "#Arquivos no Servidor#" -C -F -h -s -D --charset utf-8 -I index.html -o index.html; \
      sed -i.bak "s/©/(c)/g" ./index.html; \
      sed -i.bak "/<p class="VERSION">/d" ./index.html; \
      sed -i.bak "/tree v2.2.1 (c) 1996 - 2024 by Steve Baker and Thomas Moore <br>/d" ./index.html; \
      sed -i.bak "/HTML output hacked and copyleft (c) 1998 by Francesc Rocher <br>/d" ./index.html; \
      sed -i.bak "/JSON output hacked and copyleft (c) 2014 by Florian Sesser <br>/d" ./index.html; \
      sed -i.bak "/(c) 2001 by Kyosuke Tokoro/d" ./index.html; \
      sed -i.bak "/<br><br>/d" ./index.html; \
      sed -i.bak "s|\../|\./|" ./index.html; \
      rm /y -f ./index.html.bak;' shell {} \;
#
shopt -u dotglob  # Re-disable it afterward to restore defaults
#
