#!/bin/bash # Nome do arquivo final OUTPUT="projeto_completo.txt" # Pastas ou arquivos para ignorar (separados por |) # Ajuste conforme sua necessidade. Ex: node_modules, .git, venv, arquivos de log, etc. IGNORE="\.git|node_modules|vendor|__pycache__|\.idea|\.vscode|dist|build|target|\.lock|yarn-error.log" # Remove o arquivo anterior se existir rm -f "$OUTPUT" echo "=== INICIANDO GERAÇÃO DO ARQUIVO ===" # 1. Grava a Estrutura de Diretórios echo "Gerando estrutura de pastas..." echo "============== ESTRUTURA DO PROJETO ==============" >> "$OUTPUT" # Usa find para listar, remove o ./ do inicio e filtra os ignorados find . -maxdepth 4 -not -path '*/.*' | grep -vE "$IGNORE" | grep -v "$OUTPUT" | grep -v "$0" >> "$OUTPUT" echo -e "\n\n" >> "$OUTPUT" # 2. Grava o Conteúdo dos Arquivos echo "Lendo arquivos..." # Busca arquivos (-type f), ignora ocultos, filtra a lista de ignorados, o output e o próprio script find . -type f -not -path '*/.*' | grep -vE "$IGNORE" | grep -v "$OUTPUT" | grep -v "$0" | while read -r file; do # Verifica se o arquivo é binário (ex: imagens, executáveis) usando grep # Se for texto (-I), ele processa. if grep -qI . "$file"; then echo "Adicionando: $file" echo "==================================================================" >> "$OUTPUT" echo "ARQUIVO: $file" >> "$OUTPUT" echo "==================================================================" >> "$OUTPUT" cat "$file" >> "$OUTPUT" echo -e "\n\n" >> "$OUTPUT" else echo "Pulenado arquivo binário: $file" fi done echo "=== CONCLUÍDO ===" echo "O arquivo '$OUTPUT' foi gerado com sucesso."