nichts/nyx/homes/notashelf/programs/terminal/shell/bin/tzip/tzip.sh
2024-04-09 23:11:33 +02:00

20 lines
640 B
Bash

#!/usr/bin/env bash
mkdir -p mods/
# Loop through each subdirectory in the current directory
for subdir in */; do
# Find the most recently accessed file with a .tmod extension in the subdirectory
latest_file=$(find "$subdir" -name "*.tmod" -type f -printf "%T@ %p\n" | sort -n | tail -1 | awk '{print $2}')
# Copy the latest file found (if any) to the mods/ directory
if [[ -n $latest_file ]]; then
cp "$latest_file" "mods/"
echo "Copied $latest_file to mods/"
else
echo "No .tmod files found in $subdir"
fi
done
# Zip up the mods/ directory
zip -r mods.zip mods/
echo -en "Zipped up mods/ directory to mods.zip"