msos/export_code.sh

65 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
# Nastavitev imena izhodne datoteke
OUTPUT_FILE="code_export.txt"
# Odstrani izhodno datoteko, če že obstaja, da začnemo s čisto datoteko
if [ -f "$OUTPUT_FILE" ]; then
rm "$OUTPUT_FILE"
fi
# Poišči vse datoteke, razen skritih datotek in določenih map (npr. node_modules).
# Dodane so izjeme za slike, videoposnetke, PDF-je, arhive in druge binarne datoteke
# neposredno v ukaz 'find' za boljšo zmogljivost.
find . -type f \
-not -path "*/\.*" \
-not -path "*node_modules*" \
-not -path "*vendor*" \
-not -path "*dist*" \
-not -path "*build*" \
-not -path "*/images/*" \
-not -iname "*.jpg" -not -iname "*.jpeg" \
-not -iname "*.png" -not -iname "*.gif" \
-not -iname "*.bmp" -not -iname "*.tiff" \
-not -iname "*.svg" -not -iname "*.ico" \
-not -iname "*.webp" \
-not -iname "*.mp4" -not -iname "*.mov" \
-not -iname "*.avi" -not -iname "*.mkv" \
-not -iname "*.webm" \
-not -iname "*.mp3" -not -iname "*.wav" \
-not -iname "*.ogg" -not -iname "*.flac" \
-not -iname "*.pdf" \
-not -iname "*.zip" \
-not -iname "*.tar" \
-not -iname "*.gz" \
-not -iname "*.bz2" \
-not -iname "*.rar" \
-not -iname "*.7z" \
-not -iname "*.doc" -not -iname "*.docx" \
-not -iname "*.xls" -not -iname "*.xlsx" \
-not -iname "*.ppt" -not -iname "*.pptx" \
-not -iname "*.eot" -not -iname "*.ttf" \
-not -iname "*.woff" -not -iname "*.woff2" \
| sort | while read -r file; do
# Preskoči samo izhodno datoteko in to skripto
if [[ "$file" == "./$OUTPUT_FILE" || "$file" == "./export_code.sh" ]]; then
continue
fi
# Dodatna varnostna preverba: preskoči slikovne datoteke po MIME tipu
if file --mime-type -b "$file" | grep -qiE '^(image)/'; then
continue
fi
# Dodaj ime datoteke in njeno vsebino v izhodno datoteko
echo "\"$file\" : " >> "$OUTPUT_FILE"
echo "\"\"\"" >> "$OUTPUT_FILE"
cat "$file" >> "$OUTPUT_FILE"
echo "\"\"\"" >> "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE"
done
echo "Izvoz kode končan. Vsebina je shranjena v datoteko $OUTPUT_FILE"