473,322 Members | 1,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

FileSystemObject: how to get a file's title

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
Sep 10 '08 #1
2 5307
"fniles" wrote:
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
Sep 10 '08 #2
Thank you

"Old Pedant" <Ol*******@discussions.microsoft.comwrote in message
news:91**********************************@microsof t.com...
"fniles" wrote:
>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


Sep 12 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: John Dewbert | last post by:
*** post for FREE via your newsreader at post.newsfeed.com *** Hello, I have trouble passing a folder object (from a FileSystemObject) to a sub procedure. Consider the following code: ...
9
by: spradl | last post by:
Hi, I am trying to create a dynamic CSV file via FileSystemObject.CreateTextFile. I have no problem creating the CSV file normally but I would like to insert comments and VBScript into the...
3
by: Steve | last post by:
Hi all, FileSystemObject question... I'm trying to check if files exist or not, but the files are not sitting on the same server as our Intranet. Basically we have about 5000 photos in a...
3
by: bt | last post by:
I am just beginning with asp and have gotten an error that I need some help with. I posted a pair of files to an online ASP host server. The files are in the same directory; one is readfile.asp...
6
by: Singularity.co.uk | last post by:
Hi Does anyone know of another way to check if a file exists without using the FileSystemObject? Brendan
9
by: kermit | last post by:
I keep seeing that you can use the FileSystemObject in either VB script, or Javascript on an aspx page. I added a refrence to the scrrun.dll I added importing namespaces for 'System.Object',...
2
by: bteclt | last post by:
Can the Filesystemobject be used to manipulate files or folders on either a shared drive or on a virtual directory on the web server. I had a model that worked well in ASP but when I moved to...
3
by: brigitte | last post by:
The original problem: I need a procedure to import a csv file created by a third party application into an Access database. This file contains fields which may include commas, and when they do,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.