0

What I want to do:

  1. write a batch script to do the following
  2. loop though all dir starting with "01-"...
  3. Check if "Pictures" folder is empty or not. skip rest folders
  4. If "Pictures" folder is Empty, than print path of empty "Pictures" folders.

Output Example:

MainFolder/01-Folder3/Pictures is empty

Structure of my folder:

  1. 1st lvl... Every thing inside my "MainFolder"
  2. 2nd lvl... all folders start with a number ex: 01, 02, 03, etc...
  3. 3rd lvl... There is folder called "Pictures"... in every 3rd lvl

here is an example:

    |>MainFolder 
    |--->01-Folder1
    |------->Pictures
    |----------->pic.png
    |----------->SubPicFolder
    |------->RandomFolder1
    |------->RandomFolder2
    |--->01-Folder2
    |------->Pictures
    |----------->SubPicFolder
    |------->RandomFolder1
    |--->01-Folder3
    |------->Pictures
    |------->RandomFolder1
    |--->02-Folder1
    |------->Pictures
    |------->RandomFolder1
    |------->RandomFolder1

What I have tried?:

@echo off
for /d /r %%A in ("Pictur*") do (
    dir /a /b "%%~fA" 2>nul | findstr "^" >nul || echo %%~fA
)
pause

Problem with what I have tried:

This code does print all empty "Pictures" folder but issue is that it checks all the folder. I just want to check folder starting with "01-" and subfolder "Pictures". skip rest.

1 Answer 1

0
@echo off
for /f %%A in ('dir /a:d /b /s ^| find /i "01-" ^| find /i "pictur"') do (
echo checking %%A ...
dir /a /b "%%~fA" 2>nul | findstr "^" >nul || echo found empty: %%~fA
)
pause
1
  • Could you please edit your answer to give an explanation of why this code answers the question? Code-only answers are discouraged, because they don't teach the solution.
    – DavidPostill
    Nov 17, 2016 at 0:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .