Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to read sound file playing time?

85 views
Skip to first unread message

Dave "Crash" Dummy

unread,
May 15, 2012, 11:51:08 AM5/15/12
to
When I list sound files (wave, mp3, etc.) in Explorer, and can select a
"length" column that shows playing time for the file. Is there some way
I can retrieve that value for a sound file using script?
--
Crash

"When you get to a fork in the road, take it."
~ Yogi Berra ~

Tom Lavedas

unread,
May 15, 2012, 4:40:18 PM5/15/12
to
On May 15, 11:51 am, "Dave \"Crash\" Dummy" <inva...@invalid.invalid>
wrote:
The Shell.Application objects .GetDetailsOf() function should work to
return the "length" property ...

wsh.echo FileProperty("C:\users\tlavedas\Documents\Script\Testing\",
"chimes.wav", 27)

function FileProperty(sPath, sFileName, nProperty)
dim objShell
set oFldr = CreateObject("Shell.Application").NameSpace(sPath)
set ofile = oFldr.Parsename(sFilename)
FileProperty = oFldr.GetDetailsOf(ofile, nProperty)
end function

The value '27' is appropriate for the Length property in Win7. It is
probably different in WinXP (or not available, since it supports far
fewer). This script lists the available properties and the
corresponding number in all OS versions ...

sFolderPathspec = createobject("wscript.shell").currentdirectory

Set objShell = CreateObject ("Shell.Application")
Set objFolder = objShell.Namespace(sFolderPathspec)
Dim arrHeaders(286)
i = 0
on error resume next
do
' redim preserve arrHeaders(i)
arrHeaders(i) = i & " " & objFolder.GetDetailsOf(objFolder.Items,i)
i = i + 1
loop until err.number <> 0
on error goto 0

wsh.echo join(arrHeaders, vbcrlf)
________________________________
Tom Lavedas

Dave "Crash" Dummy

unread,
May 15, 2012, 5:00:59 PM5/15/12
to
Omigod! It works! :-)

Thanks, Tom. I will add this to my overflowing "notes" collection.
--
Crash

Committed to the search for intraterrestrial intelligence.

Dave "Crash" Dummy

unread,
May 17, 2012, 11:34:11 AM5/17/12
to
Tom Lavedas wrote:
> On May 15, 11:51 am, "Dave \"Crash\" Dummy" <inva...@invalid.invalid>
> wrote:

>> When I list sound files (wave, mp3, etc.) in Explorer, and can
>> select a "length" column that shows playing time for the file. Is
>> there some way I can retrieve that value for a sound file using
>> script?

> The Shell.Application objects .GetDetailsOf() function should work to
> return the "length" property ...

<snipped>

Is there a similar operation that will allow me to change some of the
properties, like "Title" or "DateLastModified?"
--
Crash

"I'm told that Wagner's music is not as bad as it sounds."
~ Mark Twain ~

Tom Lavedas

unread,
May 17, 2012, 12:59:30 PM5/17/12
to
On May 17, 11:34 am, "Dave \"Crash\" Dummy" <inva...@invalid.invalid>
Not really. Shell.Application does not support it. AFAIR, all
properties available there are read only.

If you have a version of MS Office, you can tap into one of its
application's DOM and read/write the properties that it supports. For
example, lookup the help for PowerePoint's .BuiltInDocumentProperties
property. It allows reading and writing of such properties as Author,
Title, keywords, etc.

Otherwise, you need to find a third party object/application. I have
no recommendations for third party support.
___________________________
Tom Lavedas

Dave "Crash" Dummy

unread,
May 17, 2012, 2:34:04 PM5/17/12
to
Tom Lavedas wrote:
> On May 17, 11:34 am, "Dave \"Crash\" Dummy" <inva...@invalid.invalid>
> wrote:
>> Tom Lavedas wrote:
>>> On May 15, 11:51 am, "Dave \"Crash\" Dummy"
>>> <inva...@invalid.invalid> wrote:
>>>> When I list sound files (wave, mp3, etc.) in Explorer, and can
>>>> select a "length" column that shows playing time for the file.
>>>> Is there some way I can retrieve that value for a sound file
>>>> using script?
>>> The Shell.Application objects .GetDetailsOf() function should
>>> work to return the "length" property ...
>> <snipped>
>>
>> Is there a similar operation that will allow me to change some of
>> the properties, like "Title" or "DateLastModified?"

> Not really. Shell.Application does not support it. AFAIR, all
> properties available there are read only.
>
> If you have a version of MS Office, you can tap into one of its
> application's DOM and read/write the properties that it supports.
> For example, lookup the help for PowerePoint's
> .BuiltInDocumentProperties property. It allows reading and writing
> of such properties as Author, Title, keywords, etc.
>
> Otherwise, you need to find a third party object/application. I have
> no recommendations for third party support.

I have a third party app that I use to change DateLastModified, which I
can run from script. I just wondered if there was a way to do it
directly, given my newfound knowledge.
--
Crash

"The fewer the facts, the stronger the opinion."
~ Arnold H. Glasow ~
0 new messages