if exist as different extension, DO

A swapping-ground for Regular Expression syntax

if exist as different extension, DO

Postby ThaDoctor72 » Sun Jan 07, 2018 3:55 pm

This has probably already been asked, but the syntax for even looking up the question is difficult to describe.
So, I have a directory of video files, some FLV, some MP4. I prefer the MP4 version IF the same filename does not exist as FLV.

So I want to delete/move/whatever any FLV file that already has an MP4 counterpart of the same filename.

Chances are, since I can't accurately describe what I want in English, writing it in CMD is not likely.
Thanks
ThaDoctor72
 
Posts: 2
Joined: Sun Jan 07, 2018 3:48 pm

Re: if exist as different extension, DO

Postby ThaDoctor72 » Sun Jan 07, 2018 4:27 pm

I finally figured out how to tell Google what I wanted, so here is the solution for the process in case anyone is interested.
However, I would still like to know how to pull this off in BRU should I have a similar task. %%~dpni was met with error in the RegEx box.

This is how I pulled it off in batch:
Code: Select all
FOR /F "usebackq delims=" %%i in ( `dir /b /s *.flv` ) do (
    IF EXIST "%%~dpni.mp4" (
        DEL "%%i"
    )
)
ThaDoctor72
 
Posts: 2
Joined: Sun Jan 07, 2018 3:48 pm


Return to Regular Expressions