-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-manifest.sh
More file actions
executable file
·45 lines (35 loc) · 1.15 KB
/
Copy pathgenerate-manifest.sh
File metadata and controls
executable file
·45 lines (35 loc) · 1.15 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
#!/bin/bash
# Navigate to the script's directory
cd "$(dirname "$0")"
# Start JSON object
echo '{' > assets/manifest.json
# Get all category directories
categories=($(ls -d assets/*/ 2>/dev/null | xargs -n 1 basename))
total=${#categories[@]}
count=0
for category in "${categories[@]}"; do
count=$((count + 1))
# Start category array
echo " \"$category\": [" >> assets/manifest.json
# Get all image files in this category
files=($(ls "assets/$category" 2>/dev/null | grep -iE '\.(jpg|jpeg|png|gif|webp)$'))
file_total=${#files[@]}
file_count=0
for file in "${files[@]}"; do
file_count=$((file_count + 1))
if [ $file_count -lt $file_total ]; then
echo " \"assets/$category/$file\"," >> assets/manifest.json
else
echo " \"assets/$category/$file\"" >> assets/manifest.json
fi
done
# End category array
if [ $count -lt $total ]; then
echo " ]," >> assets/manifest.json
else
echo " ]" >> assets/manifest.json
fi
done
# End JSON object
echo '}' >> assets/manifest.json
echo "✅ Manifest generated at assets/manifest.json"