I'm not a bash expert whatsoever, but I think this could work, I based it on the script found here: https://stackoverflow.com/questions/48757748/removing-orphaned-sidecar-files-by-extension
Run it from your picture directory. It will scan and delete all orphaned xmp files. Right now it would only show which files would be deleted. Uncomment the second to last line for actually deleting the orphaned files, or the last one to rename to orphaned files with a ".old" extension (so you can find and delete them later).
I tried it with a dir with fake contents, and it seems to work. But please, use it at your own risk.
<pre>
#!/bin/bash
shopt -s nullglob extglob;
#dir=~/mypictures
#cd $dir
# explore dirs recursively, finding .xmp files
find . -type f -name "*.xmp" | while read file
do
#echo "$file"
candidates=("${file%.*}"@() "${file%.*}".{cr2}@());
[[ ${#candidates[@]} -eq 0 ]] && echo "deleted orphaned file $file"
#[[ ${#candidates[@]} -eq 0 ]] && rm "$file"
#[[ ${#candidates[@]} -eq 0 ]] && mv "${file}" "${file}.old"
done
</pre>
<br/><hr align="left" width="300" />
Sent from the <a href="http://digikam.1695700.n4.nabble.com/digikam-users-f1735189.html">digikam-users mailing list archive</a> at Nabble.com.<br/>