[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 317
  • Last Modified:

batch file to check for file in all folder

How can I check if "results.txt" exist in all sub folder under "C:\folder\results\"?
0
CalmSoul
Asked:
CalmSoul
  • 7
  • 6
  • 5
2 Solutions
 
QlemoDeveloperCommented:
I.e. each subfolder has to contain results.txt, and you want to see which one does not?
0
 
CalmSoulAuthor Commented:
Yes
0
 
QlemoDeveloperCommented:
for /F "tokens=*" %%F in ('dir /a:d') do if not exist %%F\results.txt echo %%F

0
[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

 
QlemoDeveloperCommented:
Should give the starting folder, too, and do all folders, of course:

for /F "tokens=*" %%F in ('dir /a:d /s /b C:\folder\results\') do if not exist %%F\results.txt echo %%F
0
 
CalmSoulAuthor Commented:
So what is the output? I only want those folders list which doesn't contain results.txt
0
 
QlemoDeveloperCommented:
Try it ... It should do exactly that. If you want to try it on command line (outside of a batch file), you have to replace %% by %.

0
 
QlemoDeveloperCommented:
On command line, you should use this form, less output:

@for /F "tokens=*" %F in ('dir /a:d /s /b C:\folder\results\') do @if not exist %F\results.txt echo %F


0
 
CalmSoulAuthor Commented:
getting message "d" was unexpected at this time
0
 
QlemoDeveloperCommented:
Did you copy the code exactly as-is?
0
 
t0t0Commented:
Apologies for adding one more possible solution

@echo off
DEL %~n0.log 2>NUL

FOR /F "TOKENS=*" %%a IN ('DIR /AD /B /S c:\folder\results\*') DO (
   IF NOT EXIST %%a\results.txt (
      ECHO %%a >>%~n0.log
   )
)

IF EXIST %~n0.log (
   ECHO Some folders did not contain Results.txt. See %~n0.log for details.
)
0
 
QlemoDeveloperCommented:
Sorry??? That solution is just an expansion of mine.
0
 
CalmSoulAuthor Commented:
sorry i got confuse... I should have split points
0
 
t0t0Commented:
CalmSoul

I'm quite happy for you to summon a moderator to re-open this question providing you ACCEPT my code as the solution (as you have done above) and award Qlemo ASSISTED in the solution. I will agree to a 50/50 split in points. Finally, a grade 'A' would ensure we get the 'full' points awarded.

To summon a moderator: click on "Request Attention" (bottom right near red icon of your question above)
0
 
t0t0Commented:
In my previous post, I stated quite clearly I was happy for you to re-open this question and award points to Qlemo however, I did stipulate 3 conditions. These were:

(1) you "ACCEPT" my code as the solution, and award "ASSISTED" in the solution to Qlemo

(2) a 50/50 split in points

(3) a grade 'A'

While you satisfied  (2) and (3), you did NOT "ACCEPT" my code as the solution. I have been awarded points on the basis that I only "ASSISTED" in the solution.

This is unfair as it was in good faith that I agreed for you re-open this question.
0
 
CalmSoulAuthor Commented:
Ohh you want accepted and his assited?

If that is the case reopen the question I will do that... I am rookie is accpet multiple solutions
0
 
t0t0Commented:
CalmSoul

When you close a question you are given the option of accepting multiple comments as your solution.

The first comment you should click on is the one which you select as your ACCEPTED solution then after, you select others as ASSISTED in that solution.

I fear, because Qlemo's solution appears chronologically before mine, you clicked on that one first then proceeded to click on mine and this is why the ACCEPTEDB and ASSISTED are in the order as they are.
0
 
t0t0Commented:
Sorry, didn't realise off topic was remmoved due to not refreshing my browser before posting.
0
 
t0t0Commented:
WhackAMod

Why won't you allow me to make general comments to Qlemo? I'm not breaking any rules. I'm not going off on a rant. I'm not using unacceptable tone. Please allow me the freedom to post messages. If I am doing something wrong them please say so otherwise it appears you are spiting me.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 7
  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now