FileSystemObject: how to get a file's title

F

fniles

I am using the FileSystemObject to display the content of a directory/folder
in a browser.
I am wondering if there is a way for me to get/show the file's title (this
is the one in the property of the file, in the "Summary" tab, not the name
of the file).
I do not see the property in the file object to get the file's title.
Thank you.

strPhysicalPath = Server.MapPath(strPath)
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strPhysicalPath)

Set objCollection = objFolder.Files
For Each objItem in objCollection
strName = objItem.Name
next
 
O

Old Pedant

fniles said:
I am wondering if there is a way for me to get/show the file's title (this
is the one in the property of the file, in the "Summary" tab, not the name
of the file).

Yes, but *NOT* via the FileSystemObject.

Here's a little demo I wrote that gets all the info possible about any given
file:

<%
' you need the absolute path to the file
' here, I'm getting a file in the same directory as the ASP code
' so adjust as needed for your situation
fname = "xyz.doc"
fl = Server.MapPath( fname )
' this object is the magic to the whole thing:
Set objShell = Server.CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace( Left( fl, InStrRev( fl, "\" )-1 ) )
If Not( objFolder IS Nothing ) Then
Set objFolderItem = objFolder.ParseName( fname )
If Not( objFolderItem Is Nothing ) Then
' in actuality, only the numbers from 0 to about 20 or so and
' then a few numbers right after 1000 are ever used,
' so far as I can tell...but this overkill won't hurt:
For infoNumber = 0 To 2000
info = ""
On Error Resume Next
info = Trim( objFolder.GetDetailsOf(objFolderItem,
infoNumber) )
On Error GoTo 0
If info <> "" Then
Response.Write infoNumber & ": " & info & "<br/>"
End If
Next
End If
End If
%>

So now you can figure out which value of infoNumber corresponds to "title"
and just use that directly, instead of my clumsy (but informative!) FOR loop.

(HINT: infoNumber 10 is the title.)

Oh, what the hey...here is the output I get from looking at a "Feeds.doc"
file on my machine:

0: Feeds
1: 44 KB
2: Microsoft Word Document
3: 5/14/2008 6:42 PM
4: 9/10/2008 1:06 PM
5: 9/10/2008 1:06 PM
6: A
7: Online
8: PRIVATE\bwilkinson
9: bwilkinson
10: Feeds, Feed Management, and Feed Reconfiguration
13: 1
31: 5/14/2008 11:15 AM

6 is "A"rchive.
8 is owner, 9 is author. 0 through 6 should be obvious.
I don't know what infoNumber 13 or 31 are for.
Oh, and try this with an image file. You'll get the size of the image.
Example:

0: upArrow
1: 1 KB
2: JPEG Image
3: 9/17/2007 11:27 AM
4: 10/4/2007 2:22 PM
5: 9/10/2008 1:03 PM
6: RA
7: Online
8: PRIVATE\bwilkinson
13: 1
26: 11 x 12
27: 11 pixels
28: 12 pixels
 
F

fniles

Thank you

Old Pedant said:
Yes, but *NOT* via the FileSystemObject.

Here's a little demo I wrote that gets all the info possible about any
given
file:

<%
' you need the absolute path to the file
' here, I'm getting a file in the same directory as the ASP code
' so adjust as needed for your situation
fname = "xyz.doc"
fl = Server.MapPath( fname )
' this object is the magic to the whole thing:
Set objShell = Server.CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace( Left( fl, InStrRev( fl, "\" )-1 ) )
If Not( objFolder IS Nothing ) Then
Set objFolderItem = objFolder.ParseName( fname )
If Not( objFolderItem Is Nothing ) Then
' in actuality, only the numbers from 0 to about 20 or so and
' then a few numbers right after 1000 are ever used,
' so far as I can tell...but this overkill won't hurt:
For infoNumber = 0 To 2000
info = ""
On Error Resume Next
info = Trim( objFolder.GetDetailsOf(objFolderItem,
infoNumber) )
On Error GoTo 0
If info <> "" Then
Response.Write infoNumber & ": " & info & "<br/>"
End If
Next
End If
End If
%>

So now you can figure out which value of infoNumber corresponds to "title"
and just use that directly, instead of my clumsy (but informative!) FOR
loop.

(HINT: infoNumber 10 is the title.)

Oh, what the hey...here is the output I get from looking at a "Feeds.doc"
file on my machine:

0: Feeds
1: 44 KB
2: Microsoft Word Document
3: 5/14/2008 6:42 PM
4: 9/10/2008 1:06 PM
5: 9/10/2008 1:06 PM
6: A
7: Online
8: PRIVATE\bwilkinson
9: bwilkinson
10: Feeds, Feed Management, and Feed Reconfiguration
13: 1
31: 5/14/2008 11:15 AM

6 is "A"rchive.
8 is owner, 9 is author. 0 through 6 should be obvious.
I don't know what infoNumber 13 or 31 are for.
Oh, and try this with an image file. You'll get the size of the image.
Example:

0: upArrow
1: 1 KB
2: JPEG Image
3: 9/17/2007 11:27 AM
4: 10/4/2007 2:22 PM
5: 9/10/2008 1:03 PM
6: RA
7: Online
8: PRIVATE\bwilkinson
13: 1
26: 11 x 12
27: 11 pixels
28: 12 pixels
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top