[digiKam-users] removing orphaned xmp files under Linux

Peter Mc Donough mcd-mail-lists at gmx.net
Thu Mar 8 11:45:25 GMT 2018


Am 08.03.2018 um 12:28 schrieb Peter Mc Donough:

I better add the complete shell script

cu
Peter


#!/bin/bash
# 20180308 - entfernen ueberfluessiger "xmp/pts/pp3" -Dateien
# 
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
#

Error message:
peter at kubu2-lux:~/temp/oldies_mcd/2$ sh  ~/foto_xmp_ex.sh
/home/peter/foto_xmp_ex.sh: 5: /home/peter/foto_xmp_ex.sh: shopt: not found
/home/peter/foto_xmp_ex.sh: 12: /home/peter/foto_xmp_ex.sh: Syntax 
error: "(" unexpected (expecting "done")
peter at kubu2-lux:~/temp/oldies_mcd/2$



More information about the Digikam-users mailing list