Files
cs249r_book/tools/scripts/redownload_with_better_names.sh
Vijay Janapa Reddi d8cda0f4eb Improve image filename generation to use original names
- Updated generate_filename() to extract and use original filenames from URLs
- Removes CDN hash suffixes (e.g., 'oranges-frogs_abc123' -> 'oranges-frogs')
- Sanitizes filenames properly
- Added redownload script to rename existing auto-* images
- Added rename helper script for manual renaming if needed

Examples:
  - oranges-frogs_nHEaTqne53.png -> oranges-frogs.png
  - img_class_Oafs1LJbVZ.jpg -> img_class.jpg
  - img_3_03NVYn1A61.png -> img_3.png
2025-10-02 08:04:10 -04:00

25 lines
788 B
Bash
Executable File

#!/bin/bash
# Re-download images with better filenames
echo "🔄 Re-downloading images with proper filenames"
echo "=============================================="
# Remove old auto-* images
echo "🗑️ Removing old auto-* images..."
find quarto/contents/labs -type f -name "auto-*" -delete
# Also remove the directories if they're empty
find quarto/contents/labs -type d -name "images" -empty -delete
find quarto/contents/labs -type d \( -name "png" -o -name "jpg" -o -name "jpeg" \) -empty -delete
echo "✅ Old images removed"
echo ""
# Re-download all images from labs
echo "📥 Re-downloading images with new naming..."
python3 tools/scripts/manage_external_images.py -d quarto/contents/labs/
echo ""
echo "✅ Done! Images have been re-downloaded with proper filenames"