Files
assetto/process.sh

46 lines
1.3 KiB
Bash
Raw Normal View History

2026-02-08 14:13:30 +01:00
#!/bin/bash
set -euox pipefail
# Define Paths
SOURCE_ROOT="./cars"
2026-02-08 15:16:45 +01:00
TARGET_ROOT="/content/cars"
mkdir -p "$TARGET_ROOT"
2026-02-08 14:13:30 +01:00
tree "$SOURCE_ROOT" # DEBUG
# Find all archives recursively (zip, 7z, rar)
find "$SOURCE_ROOT" -type f \( -name "*.zip" -o -name "*.7z" -o -name "*.rar" \) | while read archive; do
# Get the filename without extension
filename=$(basename -- "$archive")
car_name="${filename%.*}"
echo "--------------------------------------"
echo "Processing: $car_name"
# Create a temp directory for extraction
temp_dir=$(mktemp -d)
2026-02-08 15:35:18 +01:00
# Extract contents
2026-02-08 16:04:41 +01:00
7z x "$archive" -o"$temp_dir" -y > /dev/null
2026-02-08 15:35:18 +01:00
2026-02-08 14:13:30 +01:00
# FILTERING LOGIC
2026-02-08 16:04:41 +01:00
find "$temp_dir/$car_name" -type f \
-not -path "**/skins/*/livery.png" \
-not -path "**/skins/*/preview.jpg" \
-not -path "**/skins/*/preview.jpeg" \
-not -name "ui_skin.json" \
-not -name "badge.png" \
-not -name "ui_car.json" \
-not -name "data.acd" \
2026-02-08 15:27:57 +01:00
-delete
2026-02-08 14:13:30 +01:00
2026-02-08 16:04:41 +01:00
find "$temp_dir/$car_name" -type d -empty -delete
2026-02-08 14:13:30 +01:00
echo "After filtering:"
2026-02-08 16:04:41 +01:00
tree "$temp_dir/$car_name"
2026-02-08 14:13:30 +01:00
2026-02-08 15:16:45 +01:00
cp -r "$temp_dir/$car_name" "$TARGET_ROOT"
2026-02-08 14:13:30 +01:00
done