[digiKam-users] removing orphaned xmp files under Linux

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


Am 08.03.2018 um 21:43 schrieb woenx:
> Yep, that's right, no output means that the command was executed
> successfully.
> 

Where is my mistake?

I create an test-folder im my home-directory,
copy three raw-files including their xmp-files,
remove one raw-file to get one ophaned xmp-file.

I added ls -l to the script and "rw2" to "candidates"

If I run the script in that folder, the output should show, at the end, 
the orphaned xmp-file but I get only the list of all five files and 
still the error message below.
The error points to  one "(" too many or too few in the line with the 
candidates comparisons.


#!/bin/bash
# 20180308 - entfernen ueberfluessiger "xmp/pts/pp3" -Dateien
# 
https://stackoverflow.com/questions/48757748/removing-orphaned-sidecar-files-by-extensionRun
#
ls -l
#
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,rw2}@());

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

-------------
error message
-------------

peter at kubu2-lux:~/test$ sh ~/foto_xmp_ex.sh
insgesamt 38332
-rw-r--r-- 1 peter peter 19478572 Apr  9  2015 
20150314_155955_AIDAluna_orgP.rw2
-rw-r--r-- 1 peter peter     6283 Jan 17 17:42 
20150314_155955_AIDAluna_orgP.rw2.xmp
-rw-r--r-- 1 peter peter 19744364 Apr  9  2015 
20150314_162153_AIDAluna_orgP.rw2
-rw-r--r-- 1 peter peter     5923 Jan 17 17:42 
20150314_162153_AIDAluna_orgP.rw2.xmp
-rw-r--r-- 1 peter peter     5924 Jan 17 17:42 
20150314_163131_AIDAluna_orgP.rw2.xmp
/home/peter/foto_xmp_ex.sh: 7: /home/peter/foto_xmp_ex.sh: shopt: not found
/home/peter/foto_xmp_ex.sh: 14: /home/peter/foto_xmp_ex.sh: Syntax 
error: "(" unexpected (expecting "done")
peter at kubu2-lux:~/test$




More information about the Digikam-users mailing list