DIR command not Refreshed

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Yossi Moses
Posts: 3
Joined: 14 Nov 2013 07:30

DIR command not Refreshed

#1 Post by Yossi Moses » 18 Dec 2013 08:55

Dear friends
The DIR command doesn't read refreshed real values of a folder.
If I have a very dynamic file that grows all the time, DIR gives any size, next DIR gives the same size until I go to the folder and press F5, then DIR gives a new bigger size.
Any ideas how to refresh from Command-Line?
Thanks
Yossi Moses

penpen
Expert
Posts: 1859
Joined: 23 Jun 2013 06:15
Location: Germany

Re: DIR command not Refreshed

#2 Post by penpen » 18 Dec 2013 13:55

I couldn't reproduce your result: The dir command is always updating:

Code: Select all

:: cmd.exe 1, same result even if replaced this dos cmd by an exe that grows extreme fast.
Z:\>for /L %a in (1,1,0x0FFFFF) do ((echo a) >> a.txt)
...
...
...

Code: Select all

:: cmd.exe 2
Z:\>for /L %a in (1,1,20) do dir a.txt

Z:\>dir a.txt
 Volume in Laufwerk C: hat keine Bezeichnung.
 Volumeseriennummer: F4EE-FCFD

 Verzeichnis von Z:\

18.12.2013  20:37             2.835 a.txt
               1 Datei(en),          2.835 Bytes
               0 Verzeichnis(se),  9.785.974.784 Bytes frei

Z:\>dir a.txt
 Volume in Laufwerk C: hat keine Bezeichnung.
 Volumeseriennummer: F4EE-FCFD

 Verzeichnis von Z:\

18.12.2013  20:37             2.838 a.txt
               1 Datei(en),          2.838 Bytes
               0 Verzeichnis(se),  9.785.974.784 Bytes frei

Z:\>dir a.txt
 Volume in Laufwerk C: hat keine Bezeichnung.
 Volumeseriennummer: F4EE-FCFD

18.12.2013  20:37             2.844 a.txt
               1 Datei(en),          2.844 Bytes
               0 Verzeichnis(se),  9.785.974.784 Bytes frei

...
...
...

Z:\>dir a.txt
 Volume in Laufwerk C: hat keine Bezeichnung.
 Volumeseriennummer: F4EE-FCFD

 Verzeichnis von Z:\

18.12.2013  20:37             2.931 a.txt
               1 Datei(en),          2.931 Bytes
               0 Verzeichnis(se),  9.785.974.784 Bytes frei

Z:\>
Maybe buffering reduces the amount of single file update in your case.

penpen

foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

Re: DIR command not Refreshed

#3 Post by foxidrive » 18 Dec 2013 18:24

In later versions of Windows when a file is being created then it may not show the increasing filesize like XP did.

Yossi Moses
Posts: 3
Joined: 14 Nov 2013 07:30

Re: DIR command not Refreshed

#4 Post by Yossi Moses » 19 Dec 2013 11:35

Thank you all
I tried it on XP and Win7, I ran in 2 separated command-line windows:
C:\>FOR /L %i IN (1, 1, 1000000) DO ECHO.X>> TEST.TXT
And
C:\NET>FOR /L %i IN (1, 1, 10000) DO DIR C:\TEST.TXT | FIND "TEST.TXT" >> DIR.TXT
And I got in Dir.TXT

12/19/2013 19:17 1,551 TEST.TXT
12/19/2013 19:17 1,563 TEST.TXT
12/19/2013 19:17 1,572 TEST.TXT
12/19/2013 19:17 1,590 TEST.TXT
12/19/2013 19:17 1,602 TEST.TXT
12/19/2013 19:17 1,614 TEST.TXT

And so on.
So, I don't know to create the situation, but in our servers the problem exists.
Thank you both very much
Yossi moses

Sponge Belly
Posts: 200
Joined: 01 Oct 2012 13:32
Location: Ireland
Contact:

Re: DIR command not Refreshed

#5 Post by Sponge Belly » 19 Dec 2013 13:53

Hi Yossi, :-)

Try the following:

Code: Select all

type dynamic-file.log >nul
dir dynamic-file.log


A tip I picked up from ss64.com’s page on the type command.

Hope this helps!

- SB

penpen
Expert
Posts: 1859
Joined: 23 Jun 2013 06:15
Location: Germany

Re: DIR command not Refreshed

#6 Post by penpen » 19 Dec 2013 14:16

Only if Sponge Bellys suggestion does not solve your problem:
Maybe the problem could be solved by creating an c++ program, that checks the filesize by using the function GetFileSize.

If this function doesn't return the real value then i'm out of ideas, but
maybe the following list (that may be incomplete) helps you finding the issue,
although the given solutions may not be realizeable as it reduces the servers capabilities.
Possible causes -> and possible solutions:
- activated file cache -> disabled it (optimize for quick removal, or something like that)
- unsynchronized shared folder -> synchronize it (don't know the exe that does it),
- Volume Shadow Copy Service (VSS) -> disable it (may not be wanted by admin)
- raid side effect on faulty hardware, maybe possible, but i never have seen it -> (search for a defective hdd and replace it)
- mixed oses on server(s) / client(s) -> update server/client Software (SAMBA, ...)

penpen

Post Reply