From abed19f8db4f08dd1599ea0f9093d256b5fc7d14 Mon Sep 17 00:00:00 2001 From: Mark Date: Wed, 8 Apr 2026 22:23:40 +0200 Subject: [PATCH] Add code export script --- export_code.sh | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 export_code.sh diff --git a/export_code.sh b/export_code.sh new file mode 100755 index 0000000..1a37df6 --- /dev/null +++ b/export_code.sh @@ -0,0 +1,64 @@ +#!/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"