fix(clear.sh): esclude _pipeline/ dal batch e supporta stem singolo
- Aggiunge argomento opzionale <stem>: cancella solo quella cartella - Esclude dal batch le dir che iniziano con _ o __ (es. _pipeline/) - Rimuove flag -f non documentato: la modalità singolo stem non chiede conferma Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+24
-6
@@ -4,10 +4,30 @@ set -euo pipefail
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
cd "$SCRIPT_DIR"
|
||||
|
||||
mapfile -t dirs < <(find . -maxdepth 1 -mindepth 1 -type d | sort)
|
||||
STEM="${1:-}"
|
||||
|
||||
if [[ -n "$STEM" ]]; then
|
||||
# ── Modalità singolo stem ─────────────────────────────────────────────
|
||||
target="./$STEM"
|
||||
if [[ ! -d "$target" ]]; then
|
||||
echo "Errore: cartella '$STEM' non trovata in conversione/."
|
||||
exit 1
|
||||
fi
|
||||
rm -rf "$target"
|
||||
echo "Rimossa: conversione/$STEM/"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# ── Modalità batch: tutti gli output (escluse cartelle infrastruttura) ────
|
||||
mapfile -t dirs < <(
|
||||
find . -maxdepth 1 -mindepth 1 -type d \
|
||||
! -name '_*' \
|
||||
! -name '__*' \
|
||||
| sort
|
||||
)
|
||||
|
||||
if [[ ${#dirs[@]} -eq 0 ]]; then
|
||||
echo "Nessuna cartella da cancellare."
|
||||
echo "Nessuna cartella di output da cancellare."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -16,10 +36,8 @@ for d in "${dirs[@]}"; do
|
||||
echo " $d"
|
||||
done
|
||||
|
||||
if [[ "${1:-}" != "-f" ]]; then
|
||||
read -r -p "Confermi? [s/N] " answer
|
||||
[[ "$answer" =~ ^[sS]$ ]] || { echo "Annullato."; exit 0; }
|
||||
fi
|
||||
read -r -p "Confermi? [s/N] " answer
|
||||
[[ "$answer" =~ ^[sS]$ ]] || { echo "Annullato."; exit 0; }
|
||||
|
||||
for d in "${dirs[@]}"; do
|
||||
rm -rf "$d"
|
||||
|
||||
Reference in New Issue
Block a user