0

All, need a help in a batch file script.

I have .txt file, the main purpose is to get the count of the file and if count is more than 1000 then create a .txt file otherwise finish the script.

I have a command in batch file as below;-

@echo on

cd C:\Windows\System32

type C:\Testfolder\Samplefile.txt| find "" /v /c

This gives me count of 1400. Now I need to include "When the count is >1000 then create a blank.txt file in a specific path otherwise dont do anything just complete the script.

Any help.

Thanks.

1 Answer 1

1

You will need to use a FOR /F command to capture the output of the FIND command.

@echo off
FOR /F "delims=" %%G in ('type C:\Testfolder\Samplefile.txt^| find /v /c ""') do set count=%%G
IF %count% gtr 1000 type nul>"C:\some path\blankfile.txt"
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot. It worked. But have one more question. Seems like Find /v /c command will work if the batch file is in C:. Our Samplefile.txt is in different server. can we do anything else to make it work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.