Get paths of folders that contain files of specific format using a .bat script
Solution 1:
@echo off
for /f usebackq^tokens^=* %%i in (`%__AppDir__%where.exe /r "D:\Folder" *.zip
`)do dir /b/a-d "%%~dpi\*"|%__AppDir__%findstr.exe /e "\.png \.jpg" >nul && (
echo\%%~dpi >>"X:\The\Full\Path\To\Your\Output\File.txt" )
- An alternative that will create the file (file.txt) on its first run, and overwrite (totally) on the second run, and "escape" possible special characters if present in the folder names:
@echo off
(for /f usebackq^tokens^=* %%i in (`;%__AppDir__%where.exe /r "D:\Folder" *.zip`
)do dir /b/a-d "%%~dpi\*"|%__AppDir__%findstr.exe /e "\.png \.jpg" >nul && (
echo\&<nul set/p .="%%~dpi"))>"X:\The\Full\Path\To\Your\Output\File.txt"
List your zip files recursively, where a zip is found, list all files again, and if any .png
or .jpg
are in this folder, echo the path of the folder where the zip was found.
Additional Resources:
-
Where
-
For
Loop -
For /F
Loop