Help with XMP clean-up command line script

I have this little command line script that runs under windows…it will clean a directory of any unmatched xmp files that have been left behind for any number of reasons…I just can’t seem to modify it to run recursively down through a folder tree…if anyone has any ideas I would be grateful…
FOR /F “delims=.” %%i IN (‘DIR *.XMP /b’) DO IF NOT EXIST %%i.JPG del %%i.JPG.XMP

Morning, @priort

Windows, eh? My rusty memory believes

Have fun!
Claes in Lund, Sweden

Thx I’ll take a look. I would be open to a bash script and I had an example but it didn’t seem to work and was multiple lines where this one was a one liner…there is a For /r command which is supposed to be recursive but it seems to alter variables in a way that it doesn’t work at least in my hands…it may be a syntax nuance… I was drawn to the command line as it was fast simple and removed un paired xmp files but not duplicates that had the _01 _02 etc. I direct matching to the image name would delete those.


Do you have access to Windows PowerShell?