FOR Command Differences on NT vs 2000

From: Tom Lavedas (tlavedas_at_hotmail.remove.com)
Date: 03/26/04

  • Next message: Bill Stewart: "Re: command prompt window > 50 lines"
    Date: Fri, 26 Mar 2004 13:24:51 -0800
    
    

    Sorry, I must have been asleep when I wrote that. The
    correct formulation is ...

    dir dummy.txt | find " 0 bytes">nul
    if not errorlevel 1 echo Is zero bytes.
    if errorlevel 1 echo Is NOT zero bytes.

    Tom Lavedas
    ===========

    >-----Original Message-----
    >If all you need to know is whether it is zero bytes or
    >not, you could do something like this (for all MS OS's I
    >can think of) ...
    >
    >dir dummy.txt | find " 0 bytes">nul
    >if not errorlevel 0 echo Not zero bytes.
    >if errorlevel 1 echo Is zero bytes.
    >
    >Tom Lavedas
    >===========
    >
    >>-----Original Message-----
    >>I'm trying to determine if a text file is empty by using
    >>the following FOR command to set the environment
    variable
    >>size_ to the number of bytes in a file:
    >>
    >>FOR %f in (dummy.txt) do set size_=%~zf
    >>
    >>This works correctly on a Win2000 server, but not on a
    >>WinNT server. On a WinNT server, the environment
    >variable
    >>size_ ends up being equal to "%~zf".
    >>
    >>Is there a way to make this work on a WinNT box or is
    >>there another method that can be used to determine if a
    >>text file is empty? I read through the 1CMCFAQ.txt
    found
    >>in tscmd.zip and searched the newsgroup, but found
    >nothing
    >>that might help. Our WinNT server current with all
    >>required updates and has had service pack 6 installed.
    >>
    >>Thanks
    >>
    >>
    >>.
    >>
    >.
    >


  • Next message: Bill Stewart: "Re: command prompt window > 50 lines"

    Relevant Pages

    • Re: Return code from WshShell.Exec
      ... The ERRORLEVEL at the end of your batch procedure IS zero, ... just like ECHO and the external FIND ... Then add an ECHO %ERRORLEVEL% or a REM. ...
      (microsoft.public.scripting.vbscript)
    • Re: Return code from WshShell.Exec
      ... The ERRORLEVEL at the end of your batch procedure IS zero, ... just like ECHO and the external FIND ... Then add an ECHO %ERRORLEVEL% or a REM. ...
      (microsoft.public.scripting.wsh)
    • FOR Command Differences on NT vs 2000
      ... if not errorlevel 0 echo Not zero bytes. ... >I'm trying to determine if a text file is empty by using ... On a WinNT server, the environment ...
      (microsoft.public.win2000.cmdprompt.admin)
    • Re: robocopy validation
      ... Robocopy did not copy any files. ... if errorlevel 8 echo **FAILED COPIES** & goto end ...
      (microsoft.public.win2000.general)
    • Re: errorlevel handling in DOS batch
      ... if NOT == echo error ... That will always fail fail because you are testing (assuming ERRORLEVEL is ... in mybat I have some thing like ...
      (comp.os.msdos.programmer)