cosmicflow/copy_latex_images.sh

29 lines
882 B
Bash
Raw Normal View History

2025-03-02 13:50:52 +05:30
## The purpose of this script is to copy all latex images to the appropriate subdirectories
rsync -avi ./content/ltximg ./public/cosmicflow-html/
# Set the source and destination directories
src_dir="./public/cosmicflow-html"
src_ltximg_dir="./public/cosmicflow-html/ltximg"
# Loop through each subdirectory
for dir in "$src_dir"/*; do
if [ -d "$dir" ]; then
dir_name=$(basename "$dir")
dst_ltximg_dir="${src_dir}/${dir_name}/ltximg"
echo "$dir_name"
# Create the destination subdirectory if it doesn't exist
if [ ! -d "$dst_ltximg_dir" ]; then
mkdir -p "$dst_ltximg_dir"
fi
# Use rsync to copy files starting with the subdirectory name as prefix
rsync -av --include="$dir_name*" --exclude="*" "${src_ltximg_dir}/" "${dst_ltximg_dir}/"
fi
done
rm -rf ./public/cosmicflow-html/ltximg/ltximg
echo "Successfully copied latex images."