FileSystemObject: how to get a file's title

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • fniles

    FileSystemObject: how to get a file's title

    I am using the FileSystemObjec t 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.CreateOb ject("Scripting .FileSystemObje ct")
    Set objFolder = objFSO.GetFolde r(strPhysicalPa th)

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


  • =?Utf-8?B?T2xkIFBlZGFudA==?=

    #2
    RE: FileSystemObjec t: how to get a file's title

    "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 FileSystemObjec t.

    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.CreateOb ject("Shell.App lication")
    Set objFolder = objShell.NameSp ace( Left( fl, InStrRev( fl, "\" )-1 ) )
    If Not( objFolder IS Nothing ) Then
    Set objFolderItem = objFolder.Parse Name( 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.GetDe tailsOf(objFold erItem,
    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\bwilkin son
    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\bwilkin son
    13: 1
    26: 11 x 12
    27: 11 pixels
    28: 12 pixels


    Comment

    • fniles

      #3
      Re: FileSystemObjec t: how to get a file's title

      Thank you

      "Old Pedant" <OldPedant@disc ussions.microso ft.comwrote in message
      news:912131A9-CD6C-4B3C-B97B-F97B18C7E1A6@mi crosoft.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 FileSystemObjec t.
      >
      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.CreateOb ject("Shell.App lication")
      Set objFolder = objShell.NameSp ace( Left( fl, InStrRev( fl, "\" )-1 ) )
      If Not( objFolder IS Nothing ) Then
      Set objFolderItem = objFolder.Parse Name( 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.GetDe tailsOf(objFold erItem,
      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\bwilkin son
      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\bwilkin son
      13: 1
      26: 11 x 12
      27: 11 pixels
      28: 12 pixels
      >
      >

      Comment

      Working...