Skip to main content
added 13 characters in body
Source Link

FWIW here is a quick one-liner to remove files where the image matches but the metadata does not:

find *_201* *_202[0-3] -type f -print | egrep -i "(jpg|arw|dng|tif|crw|cr3|nef|hif|heif|cs2|jpeg|png)" | while read file; do ofile="../$file"; if [ -f "$ofile" ]; then sha=`magick "$file" - 2>/dev/null | shasum`; osha=`magick "$ofile" - 2>/dev/null | shasum`; if [ "$sum" -eq "$osum" ]; then /bin/echo -n "-"; rm "$file"; else echo "$ofile differs - $osum vs $sum" >&2; fi; else echo "$ofile does not exist" >&2; fi; done 2> 20240527_exceptions.txt

I filtered out all the non-image c**p. Also I should not that the files I am removing are in a sub-folder. Each folder has the year appended and I don't want to delete anything from 2024. I write exceptions to a file called exceptions.txt and a string of "-" to stdout so I can see that it's doing stuff. There will be a short pause ...

I'm running this on a Mac under Sonoma so you may need to change a few details if you are a Linux person or other platform

find _201 *_202[0-3] -type f -print | egrep -i "(jpg|arw|dng|tif|crw|cr3|nef|hif|heif|cs2|jpeg|png)" | while read file; do ofile="../$file"; if [ -f "$ofile" ]; then sha=magick "$file" - 2>/dev/null | shasum; osha=magick "$ofile" - 2>/dev/null | shasum; if [ "$sum" -eq "$osum" ]; then /bin/echo -n "-"; rm "$file"; else echo "$ofile differs - $osum vs $sum" >&2; fi; else echo "$ofile does not exist" >&2; fi; done 2> 20240527_exceptions.txt

FWIW here is a quick one-liner to remove files where the image matches but the metadata does not:

I filtered out all the non-image c**p. Also I should not that the files I am removing are in a sub-folder. Each folder has the year appended and I don't want to delete anything from 2024. I write exceptions to a file called exceptions.txt and a string of "-" to stdout so I can see that it's doing stuff. There will be a short pause ...

I'm running this on a Mac under Sonoma so you may need to change a few details if you are a Linux person or other platform

find _201 *_202[0-3] -type f -print | egrep -i "(jpg|arw|dng|tif|crw|cr3|nef|hif|heif|cs2|jpeg|png)" | while read file; do ofile="../$file"; if [ -f "$ofile" ]; then sha=magick "$file" - 2>/dev/null | shasum; osha=magick "$ofile" - 2>/dev/null | shasum; if [ "$sum" -eq "$osum" ]; then /bin/echo -n "-"; rm "$file"; else echo "$ofile differs - $osum vs $sum" >&2; fi; else echo "$ofile does not exist" >&2; fi; done 2> 20240527_exceptions.txt

FWIW here is a quick one-liner to remove files where the image matches but the metadata does not:

find *_201* *_202[0-3] -type f -print | egrep -i "(jpg|arw|dng|tif|crw|cr3|nef|hif|heif|cs2|jpeg|png)" | while read file; do ofile="../$file"; if [ -f "$ofile" ]; then sha=`magick "$file" - 2>/dev/null | shasum`; osha=`magick "$ofile" - 2>/dev/null | shasum`; if [ "$sum" -eq "$osum" ]; then /bin/echo -n "-"; rm "$file"; else echo "$ofile differs - $osum vs $sum" >&2; fi; else echo "$ofile does not exist" >&2; fi; done 2> 20240527_exceptions.txt

I filtered out all the non-image c**p. Also I should not that the files I am removing are in a sub-folder. Each folder has the year appended and I don't want to delete anything from 2024. I write exceptions to a file called exceptions.txt and a string of "-" to stdout so I can see that it's doing stuff. There will be a short pause ...

I'm running this on a Mac under Sonoma so you may need to change a few details if you are a Linux person or other platform.

Source Link

FWIW here is a quick one-liner to remove files where the image matches but the metadata does not:

I filtered out all the non-image c**p. Also I should not that the files I am removing are in a sub-folder. Each folder has the year appended and I don't want to delete anything from 2024. I write exceptions to a file called exceptions.txt and a string of "-" to stdout so I can see that it's doing stuff. There will be a short pause ...

I'm running this on a Mac under Sonoma so you may need to change a few details if you are a Linux person or other platform

find _201 *_202[0-3] -type f -print | egrep -i "(jpg|arw|dng|tif|crw|cr3|nef|hif|heif|cs2|jpeg|png)" | while read file; do ofile="../$file"; if [ -f "$ofile" ]; then sha=magick "$file" - 2>/dev/null | shasum; osha=magick "$ofile" - 2>/dev/null | shasum; if [ "$sum" -eq "$osum" ]; then /bin/echo -n "-"; rm "$file"; else echo "$ofile differs - $osum vs $sum" >&2; fi; else echo "$ofile does not exist" >&2; fi; done 2> 20240527_exceptions.txt