[digiKam-users] removing orphaned xmp files under Linux

Peter Mc Donough mcd-mail-lists at gmx.net
Tue Mar 13 23:46:27 GMT 2018


Am 11.03.2018 um 14:26 schrieb Jürgen Blumenschein:
> Try this short script with the find command (But please, use it at your 
> own risk.):
> 
> find [searchpath] -name "*.xmp" -execdir 
> [path-to-script]/orphaned-xmp.sh "{}" \;
> 
> Skript:
> [juergen at tuxedo ~]$ cat ~/bin/orphaned-xmp.sh
> #!/bin/bash
> if [ $# -ne 1 ]; then
>          echo $0 entfernt verwaiste xmp-Dateien: nur ein Dateiname als 
> Argument ist erlaubt ;
>          echo $0 deletes orphaned xmp-files: only one filename as 
> argument ;
>          exit ;
> fi

# temporary folder
mkdir -p ~/temp/xmp_orphaned/

> Name=$1
> bName="$(basename "$Name" .xmp)"
> #echo arg count = $#, file "$Name", basename: "$bName"
> if [ ! -f "$bName" ]; then
>          echo "$Name" exists but "$bName" not ;

#       cp -in --verbose "$Name" ~/temp/xmp_orphaned/;
#       mv -i --verbose "$Name" ~/temp/xmp_orphaned/;

>          rm --interactive --verbose "$Name";
> #else
> #       echo "$Name" is not orhaned ;
> fi
> 
> Each file has to be confirmes. If you don't want this delete 
> "--interactive" in the script source.

Tested, it works. I expected lots of xmp-files but found just twelve 
orphaned ones.

A modification: I replaced in the script the "rm" first with "cp" and 
then with "mv" to a temp-folder, one never knows.

Thanks
Peter



More information about the Digikam-users mailing list