Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing file properties 3

Status
Not open for further replies.

StewartUK

Programmer
Joined
Feb 19, 2001
Messages
860
Location
GB
I want to be able to read the properties from a file. By this I mean the properties you see when you right click a file icon and click the properties menu entry.

I understand that the properties are in a hidden file, possibly called Associated Data Stream.

Can anyone help me?

Thanks,

Stewart
 

ADIR() gives you some properties. Or do you want more then that?

Mike Gagnon [μ].[γ].

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Hi Mike,

Oh yeah, much more than that!

You get up the properties of say a jpg file by right-clicking on it and going to the summary tab.

There are 3 folders - Image, Description & Origin and in the description folder there are properties like Title, Subject, Keywords and so on.

I have found out that this data appears to be in a hidden file associated with the file it refers to (does that make sense?!). It's that data I am trying to extract/access.

What this is is that we have a Graphics library on the network with 1000s of images. We'd like to try and build up a catalogue of these or alternatively be able to enter some keywords and find all the images that match.

I'm wondering if the Windows scripting host or something similar might work.

Thanks,

Stewart
 
Why don't you create a table that tracks jpg files. Then another table that carry catalog info of that jpg file. You can easily use treeview active in foxpro to display catalog and the use html to display the jpgs.

nick
 

NickPatel

I wonder how your suggestion will answer Stewart's request.
StewartUK said:
I want to be able to read the properties from a file.

Mike Gagnon [μ].[γ].

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Hi Stewart,

Are you looking for something like this ?
I am using Word documents in this example

Code:
oShell = CreateObject("Shell.Application")
cFolder = 'C:\My Documents'
oFolder = oShell.NameSpace(cFolder)
oItems = oFolder.Items
For each oItem in oItems
   If (upper(JustExt( oItem.Name )) == 'DOC')
      ? oItem.ExtendedProperty('Title')
      ?? '', oItem.ExtendedProperty('Subject')
   endif
Next

-- AirCon --
 
I think the is as good as it gets... if your going to want a whole directory, write the results to a text file.

Brian

Code:
*DO GetFileInfo WITH "WHOLE_DIRECTORY" &&anything else will run only one file
DO GetFileInfo WITH "" 

PROCEDURE GetFileInfo
LPARAMETERS lcType

fso = CreateObject("Scripting.FileSystemObject")
IF lcType="WHOLE_DIRECTORY"
lcFile=GETDIR()
  lcDirectory = fso.GetFolder(JUSTPATH(lcFile))
  lnFileCnt = lcDirectory.Files
  ?TRANSFORM(lnFileCnt.Count) + " Files in " + JUSTPATH(lcFile)
ELSE
lcFile=GETFILE()
File= fso.GetFile(lcFile)
ENDIF

IF EMPTY(lcFile)
 RETURN
ENDIF

IF lcType="WHOLE_DIRECTORY"
  For Each FILE In lcDirectory.FILES
  DO EnumInfor
   NEXT
  ENDFOR
ELSE
  DO EnumInfor
ENDIF
ENDPROC 

PROCEDURE EnumInfor
  ?"Filename: " + File.Name
  ?"File Type: " + File.Type
  ?"Version: " +IIF(EMPTY(fso.GetFileVersion(File.Path)),;
     "No Info",fso.GetFileVersion(File.Path))
  ?"Created: " + TTOC(File.DateCreated)
  ?"Last Modified: " + TTOC(File.DateLastModified)
  ?"Last Accessed: " + TTOC(File.DateLastAccessed)
  ?"Path: " + File.Path
  ?"Short Name: " + File.ShortName
  ?"Size: " + TRANSFORM(File.Size) + " bytes"
  ?CHR(13)
ENDPROC
 
Thanks Aircon, that got me exactly what I wanted!!

A question - in the properties sheet there are a quite a few items where the value is in a drop-down box, which suggests to me that the values of these properties are stored slightly differently.

Have you any ideas on that? I tried using the syntax
Code:
ofolder.Items(1).
at the command line but I couldn't get to the ExtendedProperty property.

Thanks for your help,

Stewart
 
Stewart,

Don't use "oFolder.Items(1)." to get the dropdown listbox. Reference each object item first then you will get all the list.
Code:
oItems = oFolder.Items
oItem = oItems.Item(1)

Regards

-- AirCon --
 
Ohh.. I forgot one thing.
The Item object is 0 (zero) based array not 1 based. So the first object item is:
Code:
oItems = oFolder.Items
oItem1 = oItems.Item(0)  && 1st item
oItem2 = oItems.Item(1)  && 2nd item
** oItem1.
** oItem2.

-- AirCon --
 
Oh yes I see.

However I am only getting 'real' values returned for properties Title, Subject, Category & Author. Properties Keyword, Rating & Comments are returning .NULL.

Any ideas?

Thanks again,

Stewart
 
I haven't clear about this. But some of the properties have different property name. For example, I get the return value for the "Comments" property:
Code:
oItem.ExtendedProperty('Comment')
** Notice the "Comment" without "s"

And for "Page Count" property, I can get the value if I put it without space: "PageCount"

So you need to play around a bit, and maybe for some properties also depends on the Associated Executable ( maybe ??? )

Regards

-- AirCon --
 
Oh yes, I changed Comments to Comment and got something back. I'll try fiddling around with it.

I'm not sure what you mean by Associated Executable. Do you mean the exe that is associated with the file extension like Word for .doc?

Thanks,

Stewart
 
Yes, that 's exactly what I meant. Apologies for my poor English :-(

-- AirCon --
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top