Script package for displaying folders, but excluding specific folders

I want this script to display all folders containing "deleted" in the folder name, but not if they are in the "done" folder.

For example: specify the folder if it is in C:\temp, and if it is in C:\temp\random_folder_name, but not if it is inC:\temp\done

dir /s "C:\temp" | findstr "\deleted"

exclude all folders with the name "done" and their contents.

+5
source share
3 answers

You are almost there.

Findstr / v returns all rows that do not contain a string

dir / ad will only show directories (Atrribut = Directory)

dir /s /ad "C:\temp" | findstr "\deleted" | findstr /v "\done"
+7
source
dir /s "C:\temp" | findstr "\deleted"|findstr /i /v "\temp\done\"

must match the score

  • \temp, , ""
+1

In many cases:

dir /b /s /aa <path>

Will do the trick. / b for less verbose output, / s for recursive (subdirectories) and / aa only for files ready for archiving. This usually refers to regular created files - it is enabled by default!

0
source

All Articles