Announcement

Collapse
No announcement yet.

Very Simple Batch

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Very Simple Batch

    Hello,

    Very simple one here. I need to check a file size, and if it is zero, delete.
    I have a batch file that FTP's to a remote machine to get a file, however even if the file does not exist, it creates a file with that name anyway, why? If I just check to see if it's size is zero after I should be ok.

  • #2
    Re: Very Simple Batch

    In a CMD box do a:

    Code:
    HELP FOR
    Include the following (adjust as required) in your CMD file:

    Code:
    for %%I in ("*.*") do if %%~zI EQU 0 echo %%I
    Cheers,

    Rick

    ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

    2006-2099 R Valstar. This post is offered "as is" for discussion purposes only with no express or implied warranty of any kind including, but not limited to, correctness or fitness for use. Nothing herein shall be construed as advice. Attempting any activity based on information in this post is done at your own risk.

    Comment


    • #3
      Re: Very Simple Batch

      Thank you, this works with a little modification, but i still don't understand the %%I parameter??

      Comment


      • #4
        Re: Very Simple Batch

        %I at the command line, %%I in a CMD file. Don't ask me why. It's the way FOR works. I believe this too is in HELP FOR.

        If you like, pick another letter than "I". I'm an old FORTRAN guy where "GOD is REAL unless declared INTEGER". I is generally the looping variable of choice for old farts like me (and it's in HELP FOR so there must be an old fart or two at Microsoft).

        Glad it worked out. I knew there was a ~ variable in FOR just for you. look at all the others. They'll come in handy down the road.
        Cheers,

        Rick

        ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

        2006-2099 R Valstar. This post is offered "as is" for discussion purposes only with no express or implied warranty of any kind including, but not limited to, correctness or fitness for use. Nothing herein shall be construed as advice. Attempting any activity based on information in this post is done at your own risk.

        Comment

        Working...
        X