[digiKam-users] removing orphaned xmp files under Linux

Peter Mc Donough mcd-mail-lists at gmx.net
Thu Mar 8 09:00:05 GMT 2018


Am 08.03.2018 um 03:30 schrieb woenx:
> 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-extensionRun
> 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.
> 

Whow! Here is the copy from:

# 
https://stackoverflow.com/questions/48757748/removing-orphaned-sidecar-files-by-extensionRun
#
shopt -s nullglob extglob;

# Get all sidecar files
for file in *.{xmp,pts,pp3}
do
   # Generate all permutations of filenames that it may belong to,
   # and let globbing delete the ones that don't exist
   candidates=("${file%.*}"@() "${file%.*}".{nef,raf,orf}@());

   # If none exist, the file can be deleted
   [[ ${#candidates[@]} -eq 0 ]] && echo rm "$file"
done
#
# --------------------

  I'll test it later with "mv" instead of "rm"

Thanks
Peter



More information about the Digikam-users mailing list