[Function] FGP - FileGetProperties

Post your working scripts, libraries and tools
kon
Posts: 1760
Joined: 29 Sep 2013, 17:11

[Function] FGP - FileGetProperties

25 Jun 2014, 19:01

FGP - FileGetProperties
Functions for retrieving extended file properties.

Example Usage

Code: [Select all] [Expand] [Download] (FGP_Example.ahk)GeSHi © Codebox Plus


Functions

Code: [Select all] [Expand] [Download] (FGP.ahk)GeSHi © Codebox Plus


File properties numbers will vary depending on your system. This is the reason some functions generate a static look-up table.
Files will not necessarily have values for every property. i.e. The "Authors" property is used by some MSOffice files, but it is blank in the majority of other cases.

References

Change Log
Last edited by kon on 05 Jul 2014, 02:46, edited 3 times in total.
User avatar
joedf
Posts: 5681
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: [Function] FGP - FileGetProperties

25 Jun 2014, 19:19

Providing an MSDN link or a list of properties would be great.
kon
Posts: 1760
Joined: 29 Sep 2013, 17:11

Re: [Function] FGP - FileGetProperties

25 Jun 2014, 20:33

I moved the reference URL's from the comments to actual links (much better, thanks joedf). Also, I added a bit of an explanation regarding property numbers varying.
User avatar
joedf
Posts: 5681
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: [Function] FGP - FileGetProperties

25 Jun 2014, 21:10

Great! :D
kon
Posts: 1760
Joined: 29 Sep 2013, 17:11

Re: [Function] FGP - FileGetProperties

27 Jun 2014, 14:49

Some updates to the functions:
  • Added the FGP_List function to get all of a file's non-blank properties.
  • Changed FGP_Init's returned array to use a zero-based index.
  • Changed FGP_Num to use a look-up table instead of looping.
elmo
Posts: 47
Joined: 09 Oct 2013, 09:08

Re: [Function] FGP - FileGetProperties

27 Jun 2014, 16:39

Quite elegant. Thank you.
kon
Posts: 1760
Joined: 29 Sep 2013, 17:11

Re: [Function] FGP - FileGetProperties

05 Jul 2014, 02:50

Update:
  • Changed FGP_Init so that the other functions all contain static references to the same PropTable object instead of each function having its own array.
  • Replaced FGP_ByName and FGP_ByNum with the new function FGP_Value. The new function accepts either a property name or number as its second parameter and returns the property value.
  • Changed FGP_Name to return -1 instead of 0 in the event the property number does not have an associated name. The reason for the change is for consistency with FGP_Num. FGP_Num cannot return 0 as an error code because 0 is a valid property number.
jiggunjer
Posts: 13
Joined: 16 Jan 2016, 04:00

Re: [Function] FGP - FileGetProperties

18 Jan 2016, 22:40

can these properties be used to differentiate a compressed (e.g. zip/rar) from a 'normal' file (e.g. txt, jpeg, etc). The compressed field from the default "FileGetAttrib" is unreliable.
User avatar
joedf
Posts: 5681
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: [Function] FGP - FileGetProperties

18 Jan 2016, 23:33

Well, you could have a custom function to check for the "file magic number" and determine zip and rar, etc
lexikos
Posts: 5407
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: [Function] FGP - FileGetProperties

19 Jan 2016, 00:27

The compressed field from the default "FileGetAttrib" is unreliable.
The "Compressed" attribute is about file system compression, not about what type of data the file contains. It's the "Compress contents to save disk space" option in the file's properties, under "Advanced". Usually names of compressed files are displayed with blue text in Explorer.

Windows does not "know" about all compressed file types natively, and it's doubtful that all of the different archiving programs mark the file in some way that's common between file types. So if you want to identify whether a file is a compressed archive or not, you need to know about each file type (filename extension or some signature within the data). Or you could utilize an external program or library, like the 7-zip DLL.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Yahoo [Bot] and 17 guests