ZIP FILE EXTRACT: THE WEDDING PHOTO PROBLEM


This simple trick saved me 100s of hours

After our wedding this year, my wife and I received nearly 3,000 photos, distributed across approximately 60 different ZIP files.

This wasn’t just a massive use of storage space. This task would require us to individually extract each ZIP file and then sort the photos into the correct folders on our USB drives.

SOLUTION

I created a Bash script that automatically iterates through all the ZIP files, pushing the photos into the appropriate folders based on their file names.

RESULT

  1. Hours saved on manual extraction and sorting
  2. Created multiple USB backups, with the ability to set up new ones at any time
  3. Peace of mind knowing our photos are safe and we own them

OVERVIEW

The script goes through and creates a folder for “Ceremony”, “Reception”, etc… and puts the photos in the correct folder

SETUP:

Step 1: cd into the directory that contains your zips and add Zip_Extract.sh Step 2: chmod +x the script “chmod +x Zip_Extract” Step 3: run ./Zip_Extract.sh in your terminal Step 4: Do whatever you want knowing you don’t have to do this!

CODE

#!/bin/bash

# Define the directory containing the zip files
ZIP_DIR="/<SOURCE PATH>" # Replace with the path where your zip files are located

# Define the destination directory on the USB drive
USB_DEST="/<TARGET PATH>" # I used unix and a usb so my path was /Volumes/<USB PATH>

# Navigate to the directory with the zip files
cd "$ZIP_DIR"

# Iterate over each zip file
for zfile in *.zip; do
  # Extract the category name from the zip file name
  CATEGORY=$(echo "$zfile" | cut -d'-' -f1)

  # Create a new directory for the category on the USB drive if it doesn't already exist
  if [ ! -d "$USB_DEST/$CATEGORY" ]; then
    mkdir -p "$USB_DEST/$CATEGORY"
  fi

  # Extract the zip file to the corresponding category directory
  unzip "$zfile" -d "$USB_DEST/$CATEGORY"
done

echo "Files have been extracted to their respective folders on the USB drive."

#chmod +x Zip_Extract.sh

PAIN

To give you an insight into ALL of the zip files I was given, they are listed below.

PAIN **List of Zips I extracted from **

Column 1Column 2Column 3
Ceremony-1.zipPreparation-8.zipReception-11.zip
Ceremony-2.zipPreparation-9.zipReception-12.zip
Ceremony-3.zipPreparation-10.zipReception-13.zip
Ceremony-4.zipPreparation-11.zipReception-14.zip
Ceremony-5.zipPreparation-12.zipReception-15.zip
Ceremony-6.zipPreparation-13.zipReception-16.zip
Ceremony-7.zipPreparation-14.zipReception-17.zip
Ceremony-8.zipPreparation-15.zipReception-18.zip
Ceremony-9.zipPreparation-16.zipReception-19.zip
Ceremony-10.zipPreparation-17.zipReception-20.zip
Ceremony-11.zipReception-1.zipReception-21.zip
Engagements-1.zipReception-2.zipReception-22.zip
Engagements-2.zipReception-3.zipReception-23.zip
Preparation-1.zipReception-4.zipReception-24.zip
Preparation-2.zipReception-5.zipReception-25.zip
Preparation-3.zipReception-6.zipRehearsal-1.zip
Preparation-4.zipReception-7.zipRehearsal-2.zip
Preparation-5.zipReception-8.zipRehearsal-3.zip
Preparation-6.zipReception-9.zipRehearsal-4.zip
Preparation-7.zipReception-10.zip

Hope you like it, thanks!

Check out the GitHub Repo Here