Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch script to list folders but exclude specific folders

I want this script to list all folders that contains "deleted" in the folder name but not if they is in a folder called "done".

For exampel: list the folder if it's in C:\temp and if it's in C:\temp\random_folder_name but not not if it's in C:\temp\done

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

short story, exclude all folders named "done" and their content.

like image 306
Tomas Avatar asked Mar 22 '13 10:03

Tomas


1 Answers

You are almost there.

Findstr /v returns all lines, that do not contain the string

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

dir /s /ad "C:\temp" | findstr "\deleted" | findstr /v "\done"
like image 69
Stephan Avatar answered Sep 28 '22 17:09

Stephan