-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgather_code.sh
More file actions
executable file
·55 lines (43 loc) · 1.29 KB
/
gather_code.sh
File metadata and controls
executable file
·55 lines (43 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# Script to gather all .asm, .c, .h files and linker.ld into one formatted txt file
# Get timestamp
TIMESTAMP=$(date +%s)
# Count files
IDCOUNT=$(find . -type f \( -name "*.asm" -o -name "*.c" -o -name "*.h" -o -name "linker.ld" \) | wc -l)
# Output filename
OUTPUT_FILE="progress/total_${IDCOUNT}_${TIMESTAMP}.txt"
# Clear output file
> "$OUTPUT_FILE"
# Function to process files
process_files() {
local ext=$1
local files=$(find . -type f -name "$ext" | sort)
for file in $files; do
echo "NAME :$file" >> "$OUTPUT_FILE"
echo "DIR:" >> "$OUTPUT_FILE"
echo "(CODE)" >> "$OUTPUT_FILE"
cat "$file" >> "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE"
echo "----()" >> "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE"
done
}
# Process linker.ld first
if [ -f "linker.ld" ]; then
echo "NAME :linker.ld" >> "$OUTPUT_FILE"
echo "DIR:" >> "$OUTPUT_FILE"
echo "(CODE)" >> "$OUTPUT_FILE"
cat "linker.ld" >> "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE"
echo "----()" >> "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE"
fi
# Process .asm files
process_files "*.asm"
# Process .c files
process_files "*.c"
# Process .h files
process_files "*.h"
echo "Created: $OUTPUT_FILE"
echo "Total files: $IDCOUNT"
echo "Timestamp: $TIMESTAMP"