Solved CMD DIR command exclude files in list

June 16, 2013 at 13:28:55
Specs: Windows XP, 4 Gigs
Hello all,

I want to execute a dir command but exclude some files from the result.

for example in a dir I have:


also I have a txt file which is located in "C:blacklist.txt" which has this entries:

now I want to use something like this:

dir C:\Folder /exclude=C:\blacklist.txt
and the result would look like this:


xcopy has exclude, any chance at dir command?

The Problem is that I will need the listed files excluded on the fly, means I can't use the method:

dir all files/folders, have them printed into a txt file and then use loop to delete the files in blacklist.txt

Thanks in advance!

See More: CMD DIR command exclude files in list

Report •

June 16, 2013 at 13:38:41
Dir does not have such a switch. But, you have already provided the answer; use xcopy. With the the /l switch as well as /exclude it will list the files (but not copy them).

Report •

June 16, 2013 at 22:42:08
✔ Best Answer
::====== script starts here ===============
:: exclude.bat 2013-06-17 12:31:57.35
@echo off & setLocal enableDELAYedeXpansioN

for /f "tokens=* delims= " %%a in ('dir/b c:\temp') do (
find /i "%%a" < blaklist.txt > nul || echo.%%a
goto :eof
::====== script ends here =================

M2 Golden-Triangle

Report •
Related Solutions

Ask Question