From d8e3f3c83db87bddae26b1b61d529b64a8a5e4b8 Mon Sep 17 00:00:00 2001 From: Gabe Farrell Date: Wed, 5 Mar 2025 00:54:11 -0500 Subject: [PATCH] bleh --- add_absolute_ep_to_monogatari.sh | 54 ++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100755 add_absolute_ep_to_monogatari.sh diff --git a/add_absolute_ep_to_monogatari.sh b/add_absolute_ep_to_monogatari.sh new file mode 100755 index 0000000..2e04384 --- /dev/null +++ b/add_absolute_ep_to_monogatari.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +# Find all .nfo files in the directory tree +find -type f -name "*.nfo" | while read -r file; do + # Extract the directory path + dir_path=$(dirname "$file") + + # Extract the filename + filename=$(basename "$file") + + # Skip specific filenames + if [[ "$filename" == "tvshow.nfo" || "$filename" == "season.nfo" ]]; then + continue + fi + + # Extract season and episode numbers using regex + if [[ "$filename" =~ S([0-9]+)E([0-9]+) ]]; then + season=${BASH_REMATCH[1]} + episode=${BASH_REMATCH[2]} + + # Convert season and episode to integers + season_num=$((10#$season)) + episode_num=$((10#$episode)) + + # Calculate absolute episode number + abs_episode=$episode_num + + # Sum episodes of previous seasons + for ((s=1; s $dir_path/$new_filename" + fi +done