Trying to run a batch file to clean up files recorded to a microSD card from a mavic 3 drone. It creates an .mp4 file (full resolution video) and a .lrf file (low resolution video). I also break up sessions of videos with a simple photo - which creates a .jpg and a .lrf. My batch file works great to move all the .mp4 files to a new "full" folder and then renames the .lrf files to .mp4.
The issue is that when it comes to the .jpg/.lrf combo, I am looking for different behavior. After moving all of the .mp4 files, I'm trying to delete the .lrf files that have a matching .jpg. I feel like I'm close using:
for /r d:\DCIM\100MEDIA\ %%I in (*.jpg) do del %%~nI.lrf 2>nul
but it's not deleting the the matching .lrf file. This does work when I run it in a command line: for /r %I in (*.jpg) do del %~nI.lrf, but I'm looking to run this as a simple batch.
After deleting the .lrf that has an associated .jpg, I rename the low-res .lrf files to .mp4 (which for my purposes is all I really need).
A simple file structure:
1.lrf
1.mp4
2.lrf
2.mp4
3.jpg
3.lrf
4.lrf
4.mp4
The desired end result:
full (folder containing the full high-res videos)
1.mp4
2.mp4
3.jpg
4.mp4
My full batch file:
@echo off
mkdir d:\DCIM\100MEDIA\full
for /r d:\DCIM\100MEDIA\ %%m in (*.mp4) do move "%%m" d:\DCIM\100MEDIA\full
for /r d:\DCIM\100MEDIA\ %%I in (*.jpg) do del %%~nI.lrf 2>nul
for /r d:\DCIM\100MEDIA\ %%l in (*.lrf) do ren "%%l" *.mp4