[digiKam-users] removing orphaned xmp files under Linux

digikam at 911networks.com digikam at 911networks.com
Thu Mar 8 17:38:31 GMT 2018


On Thu, 8 Mar 2018 10:00:05 +0100
Peter Mc Donough <mcd-mail-lists at gmx.net> wrote:

> # 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"

Watch for this script, there is a "major weakness". 

Some softwares (like darktable) create multiple xmp files (xxx_01,
xxx_02, xxx-1, xxx-2...) for the same raw file as virtual copies and
the script will also delete them.

-- 
sknahT

vyS



More information about the Digikam-users mailing list