ExtensionToLowercase v1.1 [MM2+3]

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

Moderators: Peke, Gurus

Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

ExtensionToLowercase v1.1 [MM2+3]

Post by Steegy »

ExtensionToLowercase forum post.

This script changes the file extension to lowercase for all selected files.

The script consists of 1 script file ("ExtensionToLowercase.vbs").
See How do I install scripts? for more help on installing the script.

ExtensionToLowercase.vbs (for the Scripts folder)

Code: Select all

'====================================================================================
' 
' MEDIAMONKEY SCRIPT: ExtensionToLowercase v1.1 (last updated 2007-01-02)    by   Steegy
'  Initiated on 2006-02-17
'
'  The ExtensionToLowercase script changes the file extension to lowercase for all selected files.
'
' Installation instructions: 
' - Copy this script as plain text file named ExtensionToLowercase.vbs, to the MediaMonkey Scripts folder 
' - Add a script entry to file Scripts.ini (example shown below)
'
'  [ExtensionToLowercase]
'  FileName=ExtensionToLowercase.vbs
'  ProcName=ExtensionToLowercase
'  Order=7
'  DisplayName=ExtensionToLowercase
'  Description=ExtensionToLowercase
'  Language=VBScript
'  ScriptType=0
'
'==========================================================================

Sub ExtensionToLowercase

  Dim mySongList : Set mySongList = SDB.CurrentSongList
  If mySongList.Count = 0 Then
    SDB.MessageBox "Nothing selected!", mtError, Array(mbOK)
    Exit Sub
  End If

  Dim i, mySong, Result
  For i = 0 To mySongList.Count - 1
    Set mySong = mySongList.Item(i)
    Result = FilePathExtensionToLowercase(mySong.Path)
    If Result <> "" Then
      mySong.Path = Result
      mySong.UpdateDB
    End If
  Next

End Sub


Function FilePathExtensionToLowercase(FilePath)
  FilePathExtensionToLowercase = ""

  Dim FSO : Set FSO = CreateObject("Scripting.FileSystemObject")

  If FSO.FileExists(FilePath) Then
    Dim File : Set File = FSO.GetFile(FilePath)
    If FSO.GetExtensionName(File) <> LCase(FSO.GetExtensionName(File)) Then
      FilePathExtensionToLowercase = File.ParentFolder.Path & "\" & FSO.GetBaseName(File) & "." & LCase(FSO.GetExtensionName(File))
    End If
  End If

End Function
Last edited by Steegy on Tue Apr 01, 2008 11:42 am, edited 2 times in total.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
nohitter151
Posts: 23640
Joined: Wed Aug 09, 2006 10:20 am
Location: NJ, USA
Contact:

Post by nohitter151 »

Will this script work for MM3?
MediaMonkey user since 2006
Need help? Got a suggestion? Can't find something?

Please no PMs in reply to a post. Just reply in the thread.
MoDementia
Posts: 1321
Joined: Thu Jun 15, 2006 3:26 pm
Location: Geelong, Victoria, Australia

Post by MoDementia »

I didnt work for MM2 :) but yes it works for both now

Code: Select all

'====================================================================================
'
' MEDIAMONKEY SCRIPT: ExtensionToLowercase v1.1 (last updated 2007-01-02)    by   Steegy
'  Initiated on 2006-02-17
'
'  The ExtensionToLowercase script changes the file extension to lowercase for all selected files.
'
' Installation instructions:
' - Copy this script as plain text file named ExtensionToLowercase.vbs, to the MediaMonkey Scripts folder
' - Add a script entry to file Scripts.ini (example shown below)
'
'  [ExtensionToLowercase]
'  FileName=ExtensionToLowercase.vbs
'  ProcName=ExtensionToLowercase
'  Order=7
'  DisplayName=ExtensionToLowercase
'  Description=ExtensionToLowercase
'  Language=VBScript
'  ScriptType=0
'
'==========================================================================

Sub ExtensionToLowercase

  Dim mySongList : Set mySongList = SDB.CurrentSongList
  If mySongList.Count = 0 Then
    SDB.MessageBox "Nothing selected!", mtError, Array(mbOK)
    Exit Sub
  End If

  Dim i, mySong, Result
  For i = 0 To mySongList.Count - 1
    Set mySong = mySongList.Item(i)
    Result = FilePathExtensionToLowercase(mySong.Path)
    If Result <> "" Then
      mySong.Path = Result
      mySong.UpdateDB
    End If
  Next

End Sub


Function FilePathExtensionToLowercase(FilePath)
  FilePathExtensionToLowercase = ""

  Dim FSO : Set FSO = CreateObject("Scripting.FileSystemObject")

  If FSO.FileExists(FilePath) Then
    Dim File : Set File = FSO.GetFile(FilePath)
    If FSO.GetExtensionName(File) <> LCase(FSO.GetExtensionName(File)) Then
      FilePathExtensionToLowercase = File.ParentFolder.Path & "\" & FSO.GetBaseName(File) & "." & LCase(FSO.GetExtensionName(File))
    End If
  End If

End Function
nohitter151
Posts: 23640
Joined: Wed Aug 09, 2006 10:20 am
Location: NJ, USA
Contact:

Post by nohitter151 »

Works great, thanks MoDementia!

Of course, thanks to Steegy as well :D
MediaMonkey user since 2006
Need help? Got a suggestion? Can't find something?

Please no PMs in reply to a post. Just reply in the thread.
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

Hah... "Then" was missing... strange error :-?
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
Snow123
Posts: 4
Joined: Mon Apr 21, 2008 11:45 pm
Contact:

Post by Snow123 »

This script changes the file extension to lowercase for all selected files.
Works great, thanks MoDementia! :D
MoDementia
Posts: 1321
Joined: Thu Jun 15, 2006 3:26 pm
Location: Geelong, Victoria, Australia

Post by MoDementia »

Woot I add 1 word and I get all the credit :P
Peke
Posts: 17446
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Post by Peke »

It feels great, doesn't it?
FYI little bugs are hardest to track ;)
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
Thanks

Why?

Post by Thanks »

I've always wondered why it's desirable not to have upper-case file extensions. Presumably there is some reason?

Assuming there is, is there a script to find all the tracks with an upper case file extension - i.e. before you use this script?

Many thankis. [That was a typo but I think I'll leave it as it is!]
Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Post by Bex »

Yes, my Tagging Inconsistencies script has such node. It find tons of other things as well. Link in signature.
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!

All My Scripts
thanks

just curious why

Post by thanks »

Is it bad to have some e.g. ".MP3" files extensions (instead of ".mp3")?

Is there some case when it's important to have lower case file extensions?

Thanks for the cool TI script, Bex.
Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Post by Bex »

Thanks!
Not that I know of. It's only for aesthetic reasons.
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!

All My Scripts
thanks

Post by thanks »

Bex wrote:Thanks!
Not that I know of. It's only for aesthetic reasons.
No, thank you! Tak, to be precise. Or something like that.

Crikey, I've been wondering that for such a long time. I can sleep easy now.
Guest

Re: just curious why

Post by Guest »

thanks wrote:Is it bad to have some e.g. ".MP3" files extensions (instead of ".mp3")?

Is there some case when it's important to have lower case file extensions?

Thanks for the cool TI script, Bex.
Actually, I had a big problem once with someone once that would not work with the uppercase file extensions on mp3s. Can't remember what it was now, though--possibly something for my phone.
Snow123
Posts: 4
Joined: Mon Apr 21, 2008 11:45 pm
Contact:

Post by Snow123 »

This script changes the file extension to lowercase for all selected files.
Post Reply