Books/2026.05-SGH-02/latex/chapters/syncjpg.sh
2026-06-30 08:19:02 -07:00

30 lines
660 B
Bash

#!/bin/bash
SRC="/mnt/l/GrailHeart/opus"
# Loop through all items in the current directory
for item in *; do
# Check if the item is a directory
if [ -d "$item" ]; then
if [ ! -d $SRC/$item ];
then
echo "No such source folder as $SRC/$item"
continue
fi
# Create the local destination folder if it doesn't exist
mkdir -p "$item/image"
# Copy only newer jpgs, quoting paths to handle spaces safely
cp -uv "$SRC/$item/image/"*.jpg "$item/image/" 2>/dev/null
if [ -f "$SRC/$item/*.png" ];
then
ls $SRC/$item/*.png
fi
fi
done