Streamline Your Photo Editing Workflow: How to Use a Shell Script to Prioritize Selected Images

When it comes to photo editing, efficiency is key. Recently, I faced a challenge where a subject picked out 100 priority photos from a larger batch. Given the sheer number of images, manually sorting them wasn’t practical. All pictures from my SLR were named in the DCIM_# format, so I noted the last five numbers of the selected files. To streamline the process, I wrote a shell script that automatically moves the chosen files to a new folder, allowing me to focus on the priority images first. I’m sharing this script to help others enhance their photo editing workflow.

Step-by-Step Instructions on How to Run a Shell Script

Create the Shell Script:

  • Open your favorite text editor (e.g., VSCode, Sublime Text, or even a basic text editor like Notepad).
  • Write or paste your shell script. Here’s a simple example for moving selected files:
#!/bin/bash

# Directory containing the files
DIR="{Path}"

# Subfolder to move matching files to
TO_PROCESS_DIR="${DIR}/To Process"

# Ensure the "To Process" directory exists
mkdir -p "$TO_PROCESS_DIR"

# List of substrings to check
substrings=(
  06340 06422 06500 06518 06521 06524 06539 06542 06545 06548 06553 06581
  06584 06587 06608 06611 06617 06629 06649 06662 06980 06695 06733 06734
  06737 06740 06743 06758 06761 06767 06773 06779 06787 06788 06791 06794
  06797 06815 06818 06821 06845 06878 06890 06898 06899 06941 06947 06959
  06962 06965 06970 06971 06977 06985 06986 07009 07040 07055 07062 07068
  07074 07080 07083 07086 07089 07092 07097 07101 07104 07107 07113 07119
  07128 07143 07146 07182 07185 07188 07191 07197 07200 07215 07218 07221
  07230 07291 07302 07323 07329 07332 07338 07350 07356 07359 07476 07362
  07365 07368 07389 07413 07435 07431 07461 07497 07500 07503 07506 07509
  07512 07518 07524 07527 07530 07536 07542 07548 07557 07578 07584 07593
)

# Debugging: Check if the directory exists
if [ ! -d "$DIR" ]; then
  echo "Directory $DIR does not exist."
  exit 1
fi

# Debugging: Check if there are files in the directory
if [ -z "$(ls -A "$DIR")" ]; then
  echo "No files found in the directory $DIR."
  exit 1
fi

# Loop through all files in the directory
for file in "$DIR"/*; do
  filename=$(basename "$file")
  echo "Processing file: $filename"
  moved=false
  for substring in "${substrings[@]}"; do
    if [[ "$filename" == *"$substring"* ]]; then
      echo "Found substring '$substring' in file: $filename"
      # Move the file to the "To Process" directory
      mv "$file" "$TO_PROCESS_DIR"
      moved=true
      break
    fi
  done
  if [ "$moved" = false ]; then
    echo "No matching substring found in file: $filename"
  fi
done

Save the Script:

  • Save the file with a .sh extension, for example, move_photos.sh.

Make the Script Executable:

  • Open a terminal window.
  • Navigate to the directory where your script is saved using the cd command. For example:
    cd /path/to/your/script
  • Make your script executable by running:
    chmod +x move_photos.sh

Run the Script:

  • Still in the terminal, run your script by typing:
    ./move_photos.sh

Verify the Results:

  • Check the destination directory to ensure that the files have been moved successfully.

Additional Tips:

  • Editing the File List: Modify the FILES array in the script to include the specific last five digits of the filenames you want to move.
  • Updating Directories: Ensure that the SOURCE_DIR and DEST_DIR variables are set to the correct paths on your system.

By following these steps, you can efficiently manage and prioritize your photo editing tasks, saving valuable time and effort. This shell script can be customized and expanded to suit various file management needs, making it a versatile tool in your workflow.

How to Prevent Raspberry Pi Zero from Blanking or Sleeping How to Fix ‘Converter Failed to Save File’ with Excel 2016
View Comments
There are currently no comments.