Jump to content

_FileGetProperty - Retrieves the properties of a file


BrewManNH
 Share

Recommended Posts

Do you mean Office 2007, or maybe Windows 7? I don't have access to either so I can't test it with them. I did check an xlsm file saved from Office 2016 and those poperties showed up for that version on Win10. 

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • 1 year later...

@esh.  I suggest you start a new thread in General Help and Support.  Show what you have done so far.  Explain clearly what you want to achieve and have been unsuccessful. 

Link to comment
Share on other sites

 

#include <_FileGetProperty.au3>

filter(@scriptdir & '\video.mp4')

Func _FileGetFPS($fullpath, $property)
   $prop = _FileGetProperty($fullpath, $property)
   $string = stringsplit($prop, '.', 2)
   return $string[0]
endfunc

func filter($p)
   $frames = _FileGetFPS($p, 'Frame rate')
   if ($frames < 23) then
      msgbox(1,'Video low fps', $p & @crlf & 'Frame rate: ' & $frames)
      FileDelete($p)
   endif
endfunc

video.mp4 is a regular video at 30.00 fps. filter() shows 30 < 23 being true, because the "30" is evaluating to 0. It works as expected when i remove the first character of either $string[0] or $frames before making a comparison/converting to number/int. So there is some invisible character X at the beginning of the string.

I noticed this earlier when trying to do a similar thing for grabbing frame rate. it had some character before everything else. Is this deliberate? It seems weird, but what do i know. I know it isn't white space because i tried stringstripws with 8 option for removing everything

Edited by lIlIIlIllIIIIlI
typo
Link to comment
Share on other sites

You are right,  For some reason there is a "?" (0x3F) in the beginning of the bit rate, data rate, and frame rate values.  What's really odd is the "?" doesn't show up in _ArrayDisplay of the 2D array of all properties.

Edited by TheXman
Link to comment
Share on other sites

I did a little more digging...  The "?" was just the default character for an unprintable character.

For me, the mysterious character at the beginning of the the "Frame Rate" property value is a Left-to-Right Mark (LRM).  Its unicode codepoint is U+200E.  Why some of the property values have a LRM is still a mystery.

I have slightly modified your _FileGetFPS() function to remove the LRM if it exists.  With that modification, the script works as expected.

Func _FileGetFPS($fullpath, $property)
    $prop = _FileGetProperty($fullpath, $property)

    ConsoleWrite("$prop before = " & StringToBinary($prop, 3) & @CRLF) ;Display binary wchar string

    ;If string property value starts with a Left-to-Right Mark (0x200E), then remove it.
    If VarGetType($prop) = "String" Then $prop = StringRegExpReplace($prop, "^\x{200E}", "")

    ConsoleWrite("$prop after  = " & StringToBinary($prop, 3) & @CRLF) ;Display binary wchar string

    $string = stringsplit($prop, '.', 2)
    return $string[0]
EndFunc

Console:
 

$prop before = 0x200E003300300020006600720061006D00650073002F007300650063006F006E0064
$prop after  = 0x003300300020006600720061006D00650073002F007300650063006F006E0064

 

Edited by TheXman
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...