Created
May 6, 2025 16:15
-
-
Save wrobelda/ccca17627066cc65057cb6dad099a0fd to your computer and use it in GitHub Desktop.
Remove edited photos from Google Photos Takeout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!/bin/bash | |
# Usage: ./remove_edited_duplicates.sh <source_dir> <destination_dir> | |
if [ -z "$1" ] || [ -z "$2" ]; then | |
echo "Usage: $0 <source_dir> <destination_dir>" | |
exit 1 | |
fi | |
SOURCE_DIR="$(realpath "$1")" | |
DEST_DIR="$(realpath "$2")" | |
# Find all files recursively with -edited before the extension | |
find "$SOURCE_DIR" -type f -name '*-edited.*' | while read -r edited_file; do | |
dir="$(dirname "$edited_file")" | |
base="$(basename "$edited_file")" | |
ext="${base##*.}" | |
name="${base%-edited.*}" | |
original_file="$dir/$name.$ext" | |
echo "Checking: Edited file: $edited_file | Original file: $original_file" | |
if [ -f "$original_file" ]; then | |
# Compute path relative to source dir | |
relative_path="$(realpath --relative-to="$SOURCE_DIR" "$edited_file")" | |
target_path="$DEST_DIR/$relative_path" | |
echo "Would move: $edited_file → $target_path" | |
# Uncomment these lines to actually move the file | |
# echo "Moving: $edited_file → $target_path" | |
# mkdir -p "$(dirname "$target_path")" | |
# mv "$edited_file" "$target_path" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment