files properties information

V

vtj

I know this may not be the place to post this question, but any help would be
appreciated. I have lots of podcasts and music (not Apple) on my laptop. It
runs Vista. I have Access 2007 on the computer. I like to change the titles
and subtitles of the podcasts especially so they are easier to find on the
MP3 player. Presently I use the Properties of the files in explorer to get
at the various pieces. It seems to me that if I knew how to address the
files properties in VBA I could find and update them as I do any other file
or table on my computer. I think the file itself would be addressable by its
fully qualified name. I.e. C:/MyFiles/Filename. However where would I find
the properties that could be addressed/copied/changed within that files
properties record? I'm thinking I could make a recordset of the properties
somehow and edit and update it. TIA
 
J

Jack Leach

http://www.pcreview.co.uk/forums/thread-1862574.php

The poster in this thread explains how to extract properties (headers) from
a .jpg file. Fortunately, this seems to work the same for other file types
rather than just jpg, though I'm not certain *exactly* how accurately it does
so. Nevertheless, I use it to read file properties of other types.

The post towards the bottom of the thread has a more-or-less complete
function for returning the information.

I have (elsewhere) a function that I updated from his posting that is (IMO)
a little more user friendly (especially if you don't happen to be a vba
whiz). If you'd like I can dig it up later tonight and post the function(s).

hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
V

vtj

Thank you very much. I'll review the site tonight. Being a novice at this
whole thing, if you run across your function it would be a big help.
 
J

Jack Leach

My apologies, I forgot to look for this after I got home last night. I will
make it a point to do so over the weekend.

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
J

Jack Leach

Here's the one I adapted. It may not be much easier if you're not familiar
with working with arrays. You should be able to call the function like this:

Dim strProperties() As String
Dim strPropNum4 As String
strProperties = FileGetProperties("yourpath")
strPropNum4 = strProperties(4)
'to get the 4th property (5th, actually - 0 based)


I forget the exact syntax to call it... if strProperties() doesn't work as
an array declare it as a variant and try like that. One or the other works

Dim varProperties As Variant
varProperties = FileGetProperties("yourpath")
Debug.Print varProperties(4)


This will get you the data from the file and allow you to use it, but
doesn't allow you to write the data to the file. I haven't tried doing that
so I couldn't advise.

You can modify this to put the values in a recordset as well, or return only
one value. Inside the loop For i = 0 To 34 you can save them to an recordset
rather than the array, or you can ditch the loop and add a property number
into the function argument if you want to return a specific property without
having to screw around with the array.

Anyway, I'm not sure if this is any easier for you or not, but if you want a
hand getting it setup to handle the data a little differently let me know and
I'll see what can be done.

(make sure you copy/paste both functions!)


'==============================================================================
' FileGetProperties
'
' Adapted (copied) from Michael Pierron
' http://www.pcreview.co.uk/forums/thread-1862574.php
' Purpose: Returns an array of all file properties
' Arguments: sFile: Full Path to File
' Returns: Array (Variant) of all properties
' Dependancies:
' Function lPosition%(Chain$, Char$)
' Revisions
' Rev 0
' 7/25/2009 Initial Release
'-----------------------
Public Function FileGetProperties(sFile As String) As Variant
On Error GoTo Err_Proc
Dim Ret(34) As String
'==================
Dim i As Integer
Dim T As String
'==================

With CreateObject("Shell.Application").Namespace(Left( _
sFile, lPosition(sFile, "\") - 1))

For i = 0 To 34
T = .GetDetailsOf(.parsename(Dir(sFile)), i)
If Len(T) Then
Ret(i) = .GetDetailsOf(.Items, i) & ": " & T
Debug.Print Ret(i)
End If

Next i

End With

'==================
Exit_Proc:
FileGetProperties = Ret
Exit Function
Err_Proc:
MsgBox "Error!" & vbCrLf & _
Str(Err.Number) & ": " & Err.Description, _
vbCritical, "Library Error!"
Resume Exit_Proc
Resume
End Function


Private Function lPosition%(Chain$, Char$)
'Dependant of FileGetProperties
Dim iPos%
Do
iPos = InStr(lPosition + 1, Chain, Char, 1)
If iPos Then lPosition = iPos Else Exit Do
Loop
End Function






--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
V

vtj

Thank you very much for taking the extra time to put this up. I have been
busy and have not had a chance to try it yet but wanted you to know that I
appreciated your going above and beyond.
 

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

Top