Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: zero bytes files  (Read 7117 times)

0 Members and 1 Guest are viewing this topic.

Blisk

    Topic Starter


    Intermediate

    Thanked: 1
    • Experience: Familiar
    • OS: Windows 7
    Re: zero bytes files
    « Reply #15 on: February 12, 2019, 02:50:20 PM »
    Problem is because sometimes I get 2 files with zero bytes and next one is like 10Kb.
    in this case it means software still works and I don't need to reboot PC.
    so when that happend script should only delete all zero bytes files and leave counter at zero

    Salmon Trout

    • Guest
    Re: zero bytes files
    « Reply #16 on: February 12, 2019, 02:59:37 PM »
    What do you mean 'next one'?

    Blisk

      Topic Starter


      Intermediate

      Thanked: 1
      • Experience: Familiar
      • OS: Windows 7
      Re: zero bytes files
      « Reply #17 on: February 12, 2019, 03:04:58 PM »
      like this
      12/02/2019 20:43:02.16 0 bytes dat_2019_02_12_20_35_34.log
      12/02/2019 20:43:02.17 0 bytes dat_2019_02_12_20_35_36.log
      12/02/2019 20:43:02.19 0 bytes dat_2019_02_12_20_35_37.log
      12/02/2019 20:43:02.20 0 bytes dat_2019_02_12_20_35_38.log
      12/02/2019 20:43:02.23 10 Kbytes dat_2019_02_12_20_35_39.log

      Salmon Trout

      • Guest
      Re: zero bytes files
      « Reply #18 on: February 12, 2019, 03:36:07 PM »
      So now the script must analyse all files, and if there is a nonzero size file next after a zero size file, then do nothing? This is too complex for batch. Sorry.

      Blisk

        Topic Starter


        Intermediate

        Thanked: 1
        • Experience: Familiar
        • OS: Windows 7
        Re: zero bytes files
        « Reply #19 on: February 13, 2019, 12:40:40 AM »
        So now the script must analyse all files, and if there is a nonzero size file next after a zero size file, then do nothing? This is too complex for batch. Sorry.

        Ok than please do it only with zero bytes files that will still make easier for me. Like you show me your logs
        I will go down sometimes with false flag but still better than everytime when software stops to work.

        Salmon Trout

        • Guest
        Re: zero bytes files
        « Reply #20 on: February 13, 2019, 12:58:41 AM »
        If you have some zero byte files, and a later nonzero, and then later zero size files, what then?

        Blisk

          Topic Starter


          Intermediate

          Thanked: 1
          • Experience: Familiar
          • OS: Windows 7
          Re: zero bytes files
          « Reply #21 on: February 13, 2019, 01:11:23 AM »
          If you have some zero byte files, and a later nonzero, and then later zero size files, what then?
          nothing leave until last 5 files are zero, than delete all zero bytes files and reboot

          Salmon Trout

          • Guest
          Re: zero bytes files
          « Reply #22 on: February 13, 2019, 01:37:40 PM »
          Is the folder full of files? What if there are 100 files?

          Blisk

            Topic Starter


            Intermediate

            Thanked: 1
            • Experience: Familiar
            • OS: Windows 7
            Re: zero bytes files
            « Reply #23 on: February 13, 2019, 03:01:22 PM »
            Is the folder full of files? What if there are 100 files?

            yes there is about 100 files.
            I have an idea how to solve this I will try with my lame knowledge, to solve this with script, I will be glad if you improve it.
            I will try something and if it works I will paste it here.

            Salmon Trout

            • Guest
            Re: zero bytes files
            « Reply #24 on: February 14, 2019, 12:00:30 PM »
            So, really, we need to put the files in date/time order, from first to last, and look at the last 5 files? If there are less than 5 zero size files among these, do nothing. If there are 5 (all of the last 5 files are zero size), delete all zero size files, add 1 to counter, and reboot? Repeat until counter = 3, then send email? This is not so hard and I know a way with VBS that is simple.

            Squashman



              Specialist
            • Thanked: 134
            • Experience: Experienced
            • OS: Other
            Re: zero bytes files
            « Reply #25 on: February 14, 2019, 04:15:14 PM »
            I have an idea how to solve this I will try with my lame knowledge, to solve this with script, I will be glad if you improve it.
            I will try something and if it works I will paste it here.
            I don't know to many people who increase their knowledge without trying to solve a problem. If a teacher just gave you the answers, you would learn nothing.

            patio

            • Moderator


            • Genius
            • Maud' Dib
            • Thanked: 1769
              • Yes
            • Experience: Beginner
            • OS: Windows 7
            Re: zero bytes files
            « Reply #26 on: February 14, 2019, 05:30:18 PM »
            + 1 + 1
            " Anyone who goes to a psychiatrist should have his head examined. "

            Blisk

              Topic Starter


              Intermediate

              Thanked: 1
              • Experience: Familiar
              • OS: Windows 7
              Re: zero bytes files
              « Reply #27 on: February 18, 2019, 05:00:47 AM »
              Ok I finally have time to complete this, I think this is a script which works, I tested it and it works.
              I know it should be better written but this is as far as I know to do it
              I be glad if Salmon improve it.

              Code: [Select]
              findstr /m "3" reboot_times.txt
              IF ERRORLEVEL 1 (goto H) else (goto End)
              :H
              pushd .\data
              mkdir check

              for /f "tokens=1,* delims=:" %%a in ('dir /o-d /a-d-h /b * ^| findstr /n "^"') do (
                  if %%a gtr 5 goto done
                  copy /y "%%b" .\check
              )
              :done
              popd
              pushd .\data\check
              @echo off
              SET COUNTER=0
              FOR /f "delims=" %%i IN ('dir /o:-d /b') do (
                if %%~zi EQU 0 (
                  DEL /q "%%i"
                  SET /A COUNTER+=1
                )
              )
              for /r %%F in (*) do if %%~zF==0 del "%%F"

              popd

              rmdir /q /s .\data\check

              echo %COUNTER% > null.txt


              findstr /m "5" null.txt
              IF ERRORLEVEL 1 (goto End) else (goto Z)
              :Z
              for /r %%F in (*) do if %%~zF==0 del "%%F"
              if exist "reboot_times.txt" (goto A1) else (goto B1)
              :B1
              copy /y nul reboot_times.txt
              @echo 0 > reboot_times.txt
              :A1
              for /f "tokens=* delims=" %%x in (reboot_times.txt) do (
                set /a var=%%x+1
              )
              @echo %var% > reboot_times.txt
              set "var=%var*=%"
              rem shutdown -r -f
              :End
              del /Q /F null.txt