Files
assetto/process.sh
2026-02-08 15:27:57 +01:00

48 lines
1.4 KiB
Bash

#!/bin/bash
set -euox pipefail
# Define Paths
SOURCE_ROOT="./cars"
TARGET_ROOT="/content/cars"
mkdir -p "$TARGET_ROOT"
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)
echo "Extracted to: $temp_dir"
tree "$temp_dir" # DEBUG
# Extract contents
7z x "$archive" -o"$temp_dir" -y > /dev/null
# FILTERING LOGIC
find "$temp_dir/$car_name" -not -path "./skins/*/livery.png" \
-not -path "./skins/*/preview.jpg" \
-not -path "./skins/*/preview.jpeg" \
-not -path "./skins/*/ui_skin.json" \
-not -path "./ui/badge.png" \
-not -path "./ui/ui_car.json" \
-not -path "./data.acd" \
-not -path "./physics/standard/data.acd" \
-not -path "./physics/csp/data.acd" \
-delete
echo "After filtering:"
tree "$temp_dir/$car_name"
cp -r "$temp_dir/$car_name" "$TARGET_ROOT"
done