Categories
Linux MacOS

Efficient Image Copying: A Photographer’s Workflow Hack

As a photographer, one of the challenges we often face is efficiently managing the images sent by clients. They provide us with lists of images they need, and manually copying each of them can be time-consuming. In this blog post, I’ll introduce you to a custom bash script I’ve developed to streamline this process and save you precious time.

The Problem

Manually copying images from client-provided lists can be tedious and error-prone. It’s easy to make mistakes or overlook files, especially when dealing with large collections.

The Solution – Custom Bash Script

To tackle this problem, I’ve created a custom bash script that automates the image copying process. This script takes a list of item numbers and copies the corresponding image files in a breeze.

How the Script Works

The script is designed to be simple and efficient. It reads a list of item numbers and constructs file paths based on a predefined naming convention. It then copies these files to a target directory called “Selection”. So in the new “Selection” folder you will have the images chosen by the customer.

Here’s the core logic of the script:

#!/bin/bash

# Define the target directory where you want to copy the selected files
target_directory="./Selection"

# Create the target directory if it doesn't exist
mkdir -p "$target_directory"

# Check if at least one argument is provided
if [ $# -eq 0 ]; then
    echo "Usage: $0 <item1> <item2> ..."
    exit 1
fi

# Loop through each argument (item) and copy the corresponding files
for item in "$@"; do
    # Construct the source and target file paths
    source_file="./IMG_${item}.JPG"
    target_file="${target_directory}/IMG_${item}.JPG"
    source_file_raw="./IMG_${item}.CR3"
    target_file_raw="${target_directory}/IMG_${item}.CR3"
    
    # Check if the source file exists
    if [ -e "$source_file" ]; then
        # Copy the file to the target directory
        cp "$source_file" "$target_file"
        cp "$source_file_raw" "$target_file_raw"
        echo "Copied $source_file to $target_file"
    else
        echo "File $source_file not found."
    fi
done

echo "Copying complete."

Setting Up the Script

To use this script, follow these steps:

  1. Choose a directory where you want to store your custom scripts. You can create a directory, e.g., /usr/local/bin, if it doesn’t already exist:
sudo mkdir -p /usr/local/bin

Move the script to the chosen directory:

sudo mv selection.sh /usr/local/bin/

Make the script executable:

sudo chmod +x /usr/local/bin/selection.sh

Using the Script in Your Photography Workflow

Now, you can use the script in your photography workflow. For example, if a client sends you a list of item numbers like this:

  • 2985
  • 3032
  • 3035
  • 3147
  • 3152
  • 3167

Go to your terminal and to the folder where you store your images and execute:

selection.sh 2985 3032 3035 3147 3152 3167

The script will automatically copy the corresponding image files to a “Selection” directory within the current directory. If the “Selection” directory doesn’t exist, it will be created.

Customization and Further Development

Feel free to customize the script to fit your specific needs. You can adapt the naming convention or add additional features to enhance its functionality.

This should work in both Linux and MacOS.