-1

I have a set of folders that looks like this:

Folder1

Folder2

Folder3

I need to search each folder & verify that there's NOT a subfolder called temp in it it. If there's a temp folder in there, that means there was an error.

If a temp folder is found, I'd like to have a .txt file created that lists each main folder that has a temp folder. Example of the failed.txt file:

Folder2 failed

Thanks in advance for the help!

aschipfl
  • 33,626
  • 12
  • 54
  • 99
  • Quick and dirty `dir /ad /s /b temp>failed.txt` – Squashman Mar 08 '17 at 16:59
  • Awesome! That gets me halfway there. What do I need to add if I also want to check if any of the Folders are completely empty? – beeneeb Mar 08 '17 at 17:17
  • 1
    Please be more specific. Which folders do you want to check for being empty? The root folders or the temp folder? Going forward do not change the scope of your question. – Squashman Mar 08 '17 at 17:21
  • Check root folder as well. So, if Folder1 is empty or has a temp folder, write to the text file. – beeneeb Mar 08 '17 at 17:23
  • By empty do you mean no files and no sub folders? – Squashman Mar 08 '17 at 17:31
  • Correct. No files or sub folders. – beeneeb Mar 08 '17 at 17:34
  • What have you tried on your own so far? – aschipfl Mar 08 '17 at 17:38
  • 1
    Please note that https://stackoverflow.com is not a free script/code writing service. If you tell us what you have tried so far (include the scripts/code you are already using) and where you are stuck then we can try to help with specific problems. You should also read [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask). – DavidPostill Mar 08 '17 at 17:59
  • dir /ad /s /b temp>failed.txt dir /ad /s /b 2>nul>emtpy3.txt for /d /r %1 %%A in (.) do ( dir /a /b "%%~fA" 2>nul | findstr "^" >nul || echo %%~fA ) > empty2.txt – beeneeb Mar 08 '17 at 19:19
  • To check if no files or folders exist in a directory you can use @dbenham 's code at this [link](http://stackoverflow.com/a/10818854/1417694) – Squashman Mar 08 '17 at 20:26

1 Answers1

0

Squashman's hint is close: next command searches for temp subfolder recursively, starting in current directory .\

>failed.txt dir /ad /s /b .\temp* | findstr /I /R "\\temp$"
JosefZ
  • 28,460
  • 5
  • 44
  • 83