Author Topic: File properties differ to output of windows explorer  (Read 1951 times)

ben

  • Hero Member
  • ***
  • Posts: 524
File properties differ to output of windows explorer
« on: August 29, 2015, 11:17:33 PM »
Hi Mario,

i am working on a script which checks some file properties.
I came across the following issues with the "image size" and "lastModified" property.
Could you please try to help me out.


1) Size:
File.Size seems to return a value that is always 1 Byte bigger than what the windows explorer shows

Win Explorer: 4092217 Bytes
File.Size:    4092218



2) LastModified:
File.LastModified seems to return another value than Win Explorer and your "report app".

Win Explorer:      ‎31. ‎März ‎2015, ‏‎20:12:44
File.LastModified: "31.03.2015 18:12:44
iMatchApp -> Report App (System) -> {File.Modified}: 31.03.2015 20:12:44


I can send you a sample image, if needed. But it's bigger than the allowed 2MB (~4MB)

Thanks a lot,
Ben



Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 30082
Re: File properties differ to output of windows explorer
« Reply #1 on: August 30, 2015, 09:10:28 AM »
File.DateTime returns the time in UTC. This info was missing in the help. I have added that.

I've made a few tests with the file size. On my system, the size reported by IMatch and Windows Explorer are identical.
IMatch gets the site from a standard Windows function and stores it as it is.

Which Windows version are you using?
Did you check the file size returned by the DIR command in a command prompt window? Maybe Windows Explorer is wrong?

ben

  • Hero Member
  • ***
  • Posts: 524
Re: File properties differ to output of windows explorer
« Reply #2 on: August 30, 2015, 12:40:44 PM »
Date:
Quote
File.DateTime returns the time in UTC. This info was missing in the help. I have added that.
Ok, thanks.
Is there an easy function to convert it to local time?


Size:
Quote
Which Windows version are you using?
I am using Win7, 64Bit, all current updates installed.
iMatch 5.4.18

Quote
Did you check the file size returned by the DIR command in a command prompt window? Maybe Windows Explorer is wrong?
I did some further tests:
Win Explorer:               4092217
CMD Dir:                       4092217
VBS FileSystemObject: 4092217  (see below)
iMatch File.Size:           4092218

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objF = objFSO.GetFile("Zoo_Augsburg_006.JPG")
mySize = objF.Size

Weird. Any ideas?


Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 30082
Re: File properties differ to output of windows explorer
« Reply #3 on: August 30, 2015, 12:58:54 PM »
No ideas. On my system the sizes always match. IMatch does not do anything with the file sizes it retrieves from Windows, it just stores them in the database. Did you try to force-rescan a file?

VB provides functions to manipulate date and time. You can easily add your local UTC offset.
The {Application.TimeZone}variable returns the time-zone offset in hours and minutes.

Or you use variables instead (VarParser class), which return the local time.

ben

  • Hero Member
  • ***
  • Posts: 524
Re: File properties differ to output of windows explorer
« Reply #4 on: August 30, 2015, 01:51:17 PM »
Quote
Did you try to force-rescan a file?
Ok, that did do the trick. I tried several pictures (taken the same date) of one folder. It seems like, alls files have been changed by 1 Byte. Now it works :-)


Quote
The {Application.TimeZone}variable returns the time-zone offset in hours and minutes.
Ok, i am a bit lost. I can output the Timezone, but how do i add it to the Date returned by File.LastModified?
Debug.Print context.Parse("{Application.TimeZone}")

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 30082
Re: File properties differ to output of windows explorer
« Reply #5 on: August 30, 2015, 03:57:16 PM »
Basic has built-in date and time manipulation functions. Check out DateAdd, for example.
Press <F1> while in the Script IDE to open the Basic help.

ben

  • Hero Member
  • ***
  • Posts: 524
Re: File properties differ to output of windows explorer
« Reply #6 on: August 30, 2015, 10:08:28 PM »
Thanks a lot for your quick help  :D
Great service!!

The filesize works now as it should.
For the date i use the standard VBS function instead, since it doesn't need stringmanipulation to use the timezone information.

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 30082
Re: File properties differ to output of windows explorer
« Reply #7 on: August 31, 2015, 08:15:02 AM »
This will work. Or just use the variables offered by IMatch, which already convert into local time, allow you to control the date and time formats etc.