Script to find the file size and perform an action

Posted on 2006-06-04
Last Modified: 2013-11-13
When I run the below command it check in the event viewer if there is an event 8001 and dumps the text to a txt file.

eldump  -l application -A 24 -m NTbackup -e 8001  >c:\test.txt

What I want to do is,if this command is successfull then the file size would be more then 1kb other wise file size would be zero.Depending on this criteria I want to run a another commmand.

Can you help me in how I can write a batch file to do this.
Question by:life_j
    1 Comment
    LVL 10

    Accepted Solution

    Contents of batch file:

    @echo off
    for %%a in (c:\test.txt) do if %%~za GTR 0 echo %%a is %%~za bytes

    If the specified file "c:\test.txt" does not exist or is 0 bytes then the batch file will do nothing and return
    If the specified file "c:\test.txt" has a file size greater than 0 (can be modified by changing "GTR 0" to a higher number) then it will echo the filename and file size.
    The "echo" command can be replaced with what you really want to do if the test is true.

    Let me know if you have any questions.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Edit Registry Key via Batch File 8 38
    Excel object stays open 19 56
    count7 challenge 12 52
    mapBully challenge 6 53
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    This article will show, step by step, how to integrate R code into a R Sweave document
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now