wiki:scripts:script-copia-mp3-pendrive.sh
script-copia-mp3-pendrive.sh
- script-copia-mp3-pendrive.sh
#!/usr/bin/env bash SRC="/home/user/Downloads/temp_files/mp3-car-temp/" DST="/run/media/user/MP3-CAR" # Config LIMPAR="sim" VERBOSE="sim" # Verificações [[ ! -d "$SRC" ]] && { echo "❌ $SRC não existe"; exit 1; } [[ ! -d "$DST" ]] && { echo "❌ $DST não montado"; exit 1; } cd "$SRC" || exit 1 # LIMPAR [[ "$LIMPAR" == "sim" ]] && rm -rf "$DST"/* && sync echo "📁 PASSO 1: Criando estrutura de pastas vazias (ordem alfa)..." mapfile -t pastas < <(ls -1d */ | sort) for pasta in "${pastas[@]}"; do pasta="${pasta%/}" [[ "$VERBOSE" == "sim" ]] && echo " 📂 $pasta" mkdir -p "$DST/$pasta" done echo "🎵 PASSO 2: Copiando SOMENTE MP3s (ordem GLOBAL alfabética)..." contador=0 while IFS= read -r -d '' mp3; do rel_path=$(realpath --relative-to="$SRC" "$mp3") dest_path="$DST/$rel_path" contador=$((contador + 1)) [[ "$VERBOSE" == "sim" ]] && printf " %4d: %s\n" "$contador" "$rel_path" cp -p -- "$mp3" "$dest_path" sync done < <(find . -name "*.mp3" -type f -print0 | sort -z) # RESUMO total_mp3=$(find "$DST" -name '*.mp3' | wc -l) echo "" echo "✅ FINALIZADO!" echo "📊 $total_mp3 músicas em ordem sequencial" echo "📍 $DST pronto pro carro!"
wiki/scripts/script-copia-mp3-pendrive.sh.txt · Last modified: 2026/02/12 12:12 by cleiton
