For the purpose of running a batch file that would search within all folders that live in R:\ except for those in exculde_dir.txt and then delete all files that do not match extensions in exclude_FILE.txt
I've been referring to a working answer,
Iterate all files in a directory using a 'for' loop Slightly modified, below:
for %%f in (R:\*) do ( something_here ^| findstr /I /V /L /G:"R:\exclude_FILE.txt")
in conjunction with another answer:
Windows 'findstr' command: Exclude results containing particular string
for /F "delims=" %%D in ('dir /B /S /A:D "R:" ^| findstr /I /V /L /G:"R:\exclude_DIR.txt"') do echo/%%D
Consider the following theoretical structure:
R:\DIR1\file.jpg
R:\DIR1\file.mkv
R:\DIR1\file.txt
R:\DIR2\file.jpg
R:\DIR2\file.mkv
R:\DIR2\file.txt
R:\DIR3\file.jpg
R:\DIR3\file.mkv
R:\DIR3\file.txt
R:\$RECYCLE.BIN
where the contents of the file exclude_FILE.txt
.mkv
.avi
.m4v
and exculde_DIR.txt
$RECYCLE.BIN
DIR2
but failing to get the syntax right. I'd expect only .mkv files to remain in DIR1 and DIR3, and any other directory not excluded, and the excluded DIR2 and recycle bin to be untouched. Thanks!