dt: embedded jpgs: how to easily remove?

During a recent task to finally ‘add to library’ all of my digital assets (to finally sever the link with Lightroom), I notice that my digital image folder structure now contains a very large number of embedded jpgs (and associated .xmps). Having now set the lighttable thumbnail preferences to ‘always use raw file…’, a proportion of the embedded image files have vanished, but there are plenty left.

What is the most effective way of isolating these jpgs and their .xmps so that they can be ‘trashed’? (I have some 600 folders in just one of my many Lightroom catalogs, so doing this by hand, a folder at a time, is not practical)

Operating system?

for f in $(find /tmp -name '*.jpg' -or -name '*.xmp'); do rm $f; done

Disclosure: I got this from stackexchange, because I just can’t remember all this… :crazy_face:

@ggbutcher He might be a windowsian

1 Like

find /tmp -name '*.jpg' -or -name '*.xmp' -print -delete

2 Likes

… and for a job this big I might recommend he become a msys2sian… :laughing:

I never could warm to find…

Really? I need mysys2 for this ? I’ll read up …

On the syntax of the ‘find’: forgive my ignorance, but isn’t this going to remove ALL my xmp files, including those of the form *.raw.xmp ?

You are right: the commands above will find and delete any *.jpg and any *.xmp residing under /tmp. Means good bye to an image.raw.xmp as well. Be carefull und don’t use the --delete too hasty.

1 Like

Ah, got a solution now: create a collection with the filter of ‘filename’ containing the string ‘embedded’ and then trash those - which will (I assume) also delete the associated jpg.xmp file.

(Edit) Later: confirmed: that works.

2 Likes

@LateJunction: Please say what shell you use: bash or windows or whatever.

The Windows command to delete all files with the extension “.jpg” in your current directory, and all subdirectories recursively, is:

del /S *.jpg

Similarly for “*.xmp”.

But perhaps you want to delete only *.xmp files that have the same name as a *.jpg file, and then remove all *.jpg files. Or you might want to find all pairs of files which have both a jpg and an xmp, and remove those files.

That can also be done in Windows, quite easily, but it’s too late at night for me.

Thanks for the suggestion. It’s been too late at night for me since I last used DOS 6.2 (or even 6.3) in the 80s! Anyway, using facilities built right into dt - which I should have known about - did the job very quickly and cleanly.

I must say that dt seems to be remarkably fast, even with a considerable portfolio of images.

With msys2, I’m pretty sure you could compile latest darktable, too.

Having read up about mysys2 I’m sure you are correct. However, at my time of life, it gives me no masochistic pleasure whatsoever to attempt this kind of voodoo magic. I’ll leave that to others who are less than a third of my age and with real skills.

I get it; we all have things which which we’re familiar, and things less so. It’s good @darix and others do current builds…

Glad you found a solution in dt.

Don’t be impertinent, young man!

1 Like

For %i in (*.jpg) do del %i

And I believe there is a /r for that for-command to recurse into subdirectories.

You might want to do ‘echo %i’ first, instead of ‘del %i’ to see which files would be selected.

1 Like

And this runs in Windows ?

Open a ‘cmd’ (command prompt) in windows and type for /?. Happy reading :).

I’m not saying Windows is just as good for scripting or shell hacks as a good Unix shell (as someone working with Linux for years I have colleagues telling me everytime ‘what you can do in bash…’).

But… Windows can do more then you think, even without Powershell :).

Also, for the old-skool people… don’t forget things like ‘cscript’ still exist. If you know your Visual Basic, you can use it as a scripting language :P.

(I never learned Powershell… it’s one of those ‘maybe at some point in time…’ things for me).

Happy reading indeed! Some of that stuff has not passed through my consciousness in almost 40 years and I was well past the Peter Principle point by then. My only error in trying to run the command was to choose a directory which contained no files, only sub-directories, leading to null output.

However, the command is too dangerous for me to use: I needed only to remove those jpgs
and jpg.xmps which were embedded within a raw file, Through some mindless fiddling about by an aged incompetent meddler, these had become ‘externalised’ in my folder hierarchy, with filenames which included the text string ‘_embedded’ within them. In the event, I have now found a simple, elegant and safe way of deleting those files using the collection-creation capabilities of dt.

1 Like