#! /usr/bin/env nix-shell
#! nix-shell -i bash -p bash

# Source and destination directories
SRC_DIR="/srv/pool/scrapping/JawZ/gallery-dl"
DEST_DIR="/srv/pool/scrapping/JawZ/videos-dl"

# Create destination directory if it doesn't exist
mkdir -p "$DEST_DIR"

# Find all the desired files and process them
find "$SRC_DIR" -type f \( -name "*.mp4" -o -name "*.webm" -o -name "*.sfw" -o -name "*.m4v" -o -name "*.wav" -o -name "*.m4a" -o -name "*.ytdl" -o -name "*.mkv" \) | while read -r FILE; do
  REL_PATH="${FILE#"$SRC_DIR"/}"

  DEST_PATH="$DEST_DIR/$(dirname "$REL_PATH")"
  mkdir -p "$DEST_PATH"

  mv "$FILE" "$DEST_PATH/"
done

echo "Files moved successfully, preserving the directory structure."
