Jump to content

How to get file version


ur
 Share

Recommended Posts

How to get the thrid number of a file version.

Example: Let's say I have a file with below properties.

I want only the third number like here it is 1941 as highlighted.

Is there any built in function to get it??

asdsd.png

Link to comment
Share on other sites

You can use StringSplit for splitting the return of FileGetVersion:

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Retrieve the file version of the AutoIt executable.
    Local $sFileVersion = FileGetVersion(@AutoItExe)
    Local $aSplit=StringSplit($sFileVersion,'.')
    If IsArray($aSplit) Then MsgBox($MB_SYSTEMMODAL, "", $aSplit[3])
EndFunc   ;==>Example

 

Link to comment
Share on other sites

yeah I tried the below one and working.Used the inputs from Anoop.

 

#include <MsgBoxConstants.au3>
#include <Array.au3>

$sFilePath = FileOpenDialog("Select a file to read attributes",@ScriptDir,"All (*.*)")
MsgBox(0,$sFilePath,getFileVersionBuildNumber($sFilePath))

Func getFileVersionBuildNumber($sFilePath)

$sStringName = "FileVersion"
Local $sStringValue = FileGetVersion($sFilePath, $sStringName)

If Not @error Then
    ;Display the property value.
    $b = StringSplit ( $sStringValue, '.' )[3]
    return $b
Else
    ;If error, display an error message.
    MsgBox($MB_ICONERROR, "", "Error when getting " & '"' & $sStringName  & '"')
EndIf

EndFunc

 

Link to comment
Share on other sites

10 minutes ago, ur said:

yeah I tried the below one and working.Used the inputs from Anoop.

 

#include <MsgBoxConstants.au3>
#include <Array.au3>

$sFilePath = FileOpenDialog("Select a file to read attributes",@ScriptDir,"All (*.*)")
MsgBox(0,$sFilePath,getFileVersionBuildNumber($sFilePath))

Func getFileVersionBuildNumber($sFilePath)

$sStringName = "FileVersion"
Local $sStringValue = FileGetVersion($sFilePath, $sStringName)

If Not @error Then
    ;Display the property value.
    $b = StringSplit ( $sStringValue, '.' )[3]
    return $b
Else
    ;If error, display an error message.
    MsgBox($MB_ICONERROR, "", "Error when getting " & '"' & $sStringName  & '"')
EndIf

EndFunc

 

Great to know that!!! :)

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...