Where do I get the File Extension ?

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

philby

Where do I get the File Extension ?

Post by philby »

I am writing (my first) script that will process the current selection, check for the presence of Lyrics, and set a "Y"/"N" flag in the Custom1 field accordingly. If the file is of a type that does not store Lyrics, I want to store an "X" in Custom1 instead. I have the basic script working except for the ability to identify the file extension (mp3, wma, etc). What is the name of the field that stores this value, or must it be parsed from the full filename ?
If parsing is required, could I have an example please. Many thanks,
Philby
pah68
Posts: 1504
Joined: Wed Apr 07, 2004 5:26 pm
Location: Sydney, Australia

Post by pah68 »

I found that using an auto playlist that looks for any instance of the letter 'a' in the lyrics field works for me. Don't need to waste a custom field for it either.
philby

Post by philby »

Thanks PAH68,

Being new to MM, how do you set up an "Auto Playlist that looks for any instance of the letter 'a' in the lyrics field" ?

Thanks for your prompt reply
philby

Post by philby »

Dont worry - the Help seems to cever it adequately.
Philby
onkel_enno
Posts: 2153
Joined: Fri Jan 14, 2005 1:45 am
Location: Germany
Contact:

Re: Where do I get the File Extension ?

Post by onkel_enno »

philby wrote:... or must it be parsed from the full filename?
Yes, that's the way!
philby

Post by philby »

Thanks Guys.

onkel_enno - how ? (new to VBscript)

pah68 - Have already got the AutoPlaylist working for tracks with lyrics. So now I want to know which tracks DO NOT contain lyrics ????

Philby
onkel_enno
Posts: 2153
Joined: Fri Jan 14, 2005 1:45 am
Location: Germany
Contact:

Post by onkel_enno »

philby wrote: onkel_enno - how ? (new to VBscript)
Should be s.th like

Code: Select all

ext = Right(Song.Path,3)
Song = the selected song in mm

Not tested :wink:
philby

Post by philby »

Gotcha !

Thanx, it worked like a charm.

Philby
Philby

Post by Philby »

Back Again.

Where can I find a "language/syntax" reference for VBscript ?

I want to take the "Path" field, find the last ocurrence of the "/" character, and remove all characters to the right of that character. Just don't know the syntax of the "pos" "mid" string manipulation functions.

Philby
onkel_enno
Posts: 2153
Joined: Fri Jan 14, 2005 1:45 am
Location: Germany
Contact:

Post by onkel_enno »

If you have MS Office you could use the VBA-Help.
Otherwise I could send you a VB-Help-File via e-mail (maybe it's anywhere in the I-Net too).

Mid(string, start[, length])
InStr([start, ]string1, string2[, compare])

Edit: This includes a VB-Script-Help-File:
http://download.microsoft.com/download/ ... oc56en.exe
philby

Post by philby »

onkel_enno

Thanks again for the prompt reply

I guess i'm too impatient. A quick Google search uncovered this site

http://www.w3schools.com/vbscript/vbscr ... ctions.asp

Seems to list all the syntax in various categories.

Thanks for your link. That is also helpful. Think I might now be armed with all the resources necessary.

Philby
onkel_enno
Posts: 2153
Joined: Fri Jan 14, 2005 1:45 am
Location: Germany
Contact:

Post by onkel_enno »

philby wrote:Think I might now be armed with all the resources necessary.
If you still miss s.th. you are welcome to ask :D
Peke
Posts: 17484
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Post by Peke »

Here is solution for all Extensions (FLAC,WAV, RA, MPC, MAC,...)

Code: Select all

Dim  SongPath, ext
SongPath = Song.Path
ext = Right(SongPath,4)
If Mid(ext,2,1) = "." Then
  ext = Right(SongPath,2)
ElseIf Mid(ext,1,1) = "." Then
  ext = Right(SongPath,3)
End If
This will check if fileextension is 2-4 Chars in case od FLAC and RA file types.
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
onkel_enno
Posts: 2153
Joined: Fri Jan 14, 2005 1:45 am
Location: Germany
Contact:

Post by onkel_enno »

better way:

Code: Select all

if InStr(1, SongPath, ".") then ext = Mid(SongPath, InStrRev(SongPath, ".") + 1)
:lol:
pah68
Posts: 1504
Joined: Wed Apr 07, 2004 5:26 pm
Location: Sydney, Australia

Post by pah68 »

philby wrote:pah68 - Have already got the AutoPlaylist working for tracks with lyrics. So now I want to know which tracks DO NOT contain lyrics ????

Philby

Use "doesn't contain" as the condition :wink:
Post Reply