[digiKam-users] removing orphaned xmp files under Linux
Chris Green
cl at isbd.net
Thu Mar 8 14:03:22 GMT 2018
digikam at 911networks.com wrote:
> On Wed, 7 Mar 2018 21:35:30 +0000
> Chris Green <cl at isbd.net> wrote:
>
> > Do they have a suffix or at least a recognisble pattern in their
> > name? If so it's dead easy using the 'find' command:-
> >
> > find <name of top level directory> -name '*.xmp'
> >
> > If you want to remove the files as well:-
> >
> > find <name of top level directory> -name '*.xmp' -exec rm {} \;
>
> I don't think so. It finds ALL the files that have an .xmp
> extension, including all the files that have a raw counterpart.
>
> Doing the rm will delete all the xmp files
>
> > find ~/darktable/ -name '*.xmp'|less
>
> Here is an xmp from the find:
>
> /home/froggy/darktable/people/photographers/photographers-2014/photographers-20141107-0363.cr2.xmp
>
> > ls /home/froggy/darktable/people/photographers/photographers-2014/photographers-20141107-0363*
>
> /home/froggy/darktable/people/photographers/photographers-2014/photographers-20141107-0363.cr2
> /home/froggy/darktable/people/photographers/photographers-2014/photographers-20141107-0363.cr2.xmp
>
OK, that's why I asked "Do they have a suffix...", I meant the orphan
ones.
So you'll have to write a simple (bash?) script that uses find (as
above) to find all the xmp files and then removes only the orphans.
The logic would be something like:-
find an .xmp file
strip off the .xmp (use basename)
find the 'parent' file (the one with the .xmp removed)
if the above fails then remove the .xmp file
--
Chris Green
ยท
More information about the Digikam-users
mailing list