Programatically Read file attributes

Last post 03-17-2009 12:39 AM by ARobinso0502. 17 replies.
Page 1 of 2 (18 items) 1 2 Next >
Sort Posts: Previous Next
  • 12-06-2004 6:24 PM

    • babgVant
    • Top 50 Contributor
    • Joined on 08-13-2004
    • Chicago, IL
    • Special Member

    Programatically Read file attributes

    I converted a bunch of dvr-ms files to wmvs using dcut (great tool btw), and I wanted to rename them all to Subtitle.wmv using vbscript (or one of the dotnet languages). But I can't figure out how to read that off of the file, does anyone know offhand how to do this?
  • 12-06-2004 11:42 PM In reply to

    • Kristian
    • Top 500 Contributor
    • Joined on 10-13-2003
    • Oslo / Norway
    • Member

    RE: Programatically Read file attributes

    system.IO.File.Move(srcFilename,destFilename)

    But what has that to do with file attributes?

    Using MyDVDs? http://www.e-Home.no/metaservices/
  • 12-07-2004 7:31 AM In reply to

    • babgVant
    • Top 50 Contributor
    • Joined on 08-13-2004
    • Chicago, IL
    • Special Member

    RE: Programatically Read file attributes

    It's not the renaming part I'm having trouble with, it's reading the subtitle from the file's attributes.

    For eg. I have a file in the standard dvr-ms naming format

    channel_time.dvr-ms, i converted it with dcut, so now it's channel_time.wmv; I want it to be named Title - Subtitle.wmv using the file's attributes (like dvr2wmv will do). I just can't figure out how to get the title and subtitle from the file.
  • 12-07-2004 8:08 AM In reply to

    • Kristian
    • Top 500 Contributor
    • Joined on 10-13-2003
    • Oslo / Norway
    • Member

    RE: Programatically Read file attributes

    So what you need is a way to get the tag from the wmv file ?

    (in that case I think I can help you)

     

    Using MyDVDs? http://www.e-Home.no/metaservices/
  • 12-07-2004 10:50 AM In reply to

    • babgVant
    • Top 50 Contributor
    • Joined on 08-13-2004
    • Chicago, IL
    • Special Member

    RE: Programatically Read file attributes

    yep, well dvr-ms and wmv files...
  • 12-14-2004 12:44 PM In reply to

    • Aaron Ward
    • Not Ranked
    • Joined on 10-14-2003
    • Running Springs, CA, USA
    • Member

    RE: Programatically Read file attributes

    I have some code you can use.  send me an email to: aaron(at)wardfamily(dot)cc

     

    Thanks!

     

    Thanks,

    "Minds are like parachutes.  They work best when open."

  • 12-14-2004 1:25 PM In reply to

    • babgVant
    • Top 50 Contributor
    • Joined on 08-13-2004
    • Chicago, IL
    • Special Member

    RE: Programatically Read file attributes

  • 12-20-2004 4:31 PM In reply to

    • Turge
    • Top 200 Contributor
    • Joined on 10-17-2004
    • Regular

    RE: Programatically Read file attributes

    Since corresponding by email doesn't do any good to anyone else, I will post some sample code to retrieve a file's extended properties:

    Dim arrHeaders(35)
    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.Namespace(
    "C:\Folder")
    For i = 0 to 34
        arrHeaders(i) = objFolder.GetDetailsOf(objFolder.Items, i)
    Next
    For Each strFileName in objFolder.Items
        For i = 0 to 34
            Wscript.Echo i & vbtab & arrHeaders(i) _
                &
    ": " & objFolder.GetDetailsOf(strFileName, i)
        Next
    Next
    The example enumerates every file in a folder and displays each of the 35 properties available: 
    0    Name
    1Size
    2Type
    3Date Modified
    4Date Created
    5Date Accessed
    6Attributes
    7Status
    8Owner
    9Author
    10Title
    11Subject
    12Category
    13Pages
    14Comments
    15Copyright
    16Artist
    17Album Title
    18Year
    19Track Number
    20Genre
    21Duration
    22Bit Rate
    23Protected
    24Camera Model
    25Date Picture Taken
    26Dimensions
    27Not used
    28Not used
    29Not used
    30Company
    31Description
    32File Version
    33Product Name
    34Product Version
    If anyone needs help understanding this, let me know,
    Steve
  • 12-21-2004 7:05 AM In reply to

    • babgVant
    • Top 50 Contributor
    • Joined on 08-13-2004
    • Chicago, IL
    • Special Member

    RE: Programatically Read file attributes

    Excellent. Thanks, I emailed Aarron and hadn't heard anything back, so I'd pretty much given up. Thanks.
  • 12-22-2004 9:15 AM In reply to

    • babgVant
    • Top 50 Contributor
    • Joined on 08-13-2004
    • Chicago, IL
    • Special Member

    RE: Programatically Read file attributes

    Figured I'd post up the result...

    Thanks again.

    Const folderName = "C:\Folder\"

    Dim objShell, objFolder, strFileName, fso, f, title, subtitle

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.Namespace(folderName)

    For Each strFileName in objFolder.Items
    title = objFolder.GetDetailsOf(strFileName, 10)
    subtitle = objFolder.GetDetailsOf(strFileName, 17)
    Set f = fso.GetFile(folderName & strFileName)
    f.name = title & " - " & subtitle & right(f.name, len(f.name) - InStrRev(f.name, ".") + 1)
    set f = nothing
    Next

    Set objFolder = nothing
    Set objShell = nothing
    Set fso = nothing
  • 12-26-2004 6:21 AM In reply to

    • babgVant
    • Top 50 Contributor
    • Joined on 08-13-2004
    • Chicago, IL
    • Special Member

    RE: Programatically Read file attributes

    change 17 to 29 for dvr-ms files
  • 01-05-2005 7:38 PM In reply to

    • babgVant
    • Top 50 Contributor
    • Joined on 08-13-2004
    • Chicago, IL
    • Special Member

    RE: Programatically Read file attributes

    Does anyone know how to do this same thing in dot.net?
  • 01-07-2005 1:44 PM In reply to

    • babgVant
    • Top 50 Contributor
    • Joined on 08-13-2004
    • Chicago, IL
    • Special Member

    RE: Programatically Read file attributes

    nm, figured it out...

    add a reference to ...\system32\shell32.dll and

    Dim s As New Shell32.Shell
    Dim f As Shell32.Folder = s.NameSpace("C:\Folder")
    Dim i As Shell32.FolderItem = f.P****Name("file.ext")

    If (Not i Is Nothing) Then
    MessageBox.Show(f.GetDetailsOf(i, 17))
    End If

    i = Nothing
    f = Nothing
    s = Nothing

    will work...
  • 01-07-2005 3:58 PM In reply to

    • Turge
    • Top 200 Contributor
    • Joined on 10-17-2004
    • Regular

    RE: Programatically Read file attributes

    Nice work babgVant.. looked high and low for your solution!

    So, for reference:

    10 - Name of show
    29 - Episode title
    30 - Program description

  • 01-07-2005 8:20 PM In reply to

    • babgVant
    • Top 50 Contributor
    • Joined on 08-13-2004
    • Chicago, IL
    • Special Member

    RE: Programatically Read file attributes

    weird, P****Name should be P****Name
Page 1 of 2 (18 items) 1 2 Next >


Terms of Service | Privacy Statement | Code of Conduct | About