Rafał Skowera
Rafał Skowera

Reputation: 25

Find directory without files Windows

I have directory tree. How to get list of directories without file xyz.xml using for example batch scripting or Windows browser? //If is it possible I want to save list of this directories in Excel file.

I have tried to get answer or tips, there are some for Unix, but I work on Windows 10.

Upvotes: 2

Views: 940

Answers (1)

npocmaka
npocmaka

Reputation: 57322

change the file you want to check for and the root directory at the beginning of the script.

@echo off

set "root_dir=."
set "file=xyz.xyz"

for /d /r "%root_dir%" %%# in (*) do (
    if not exist "%%#\%file%" echo %%#
)

For not recursive search:

@echo off

set "root_dir=."
set "file=xyz.xyz"
pushd "%root_dir%"
for /d   %%# in (*) do (
    if not exist "%%~f#\%file%" echo %%~f#
)
popd

Upvotes: 3

Related Questions