' Save and then rename this file to have file extention ".vbs"
'
' rev 0.09 - June 2015 by Hans R Lønningdal http://snw.lonningdal.no
' VB Script will scan through my music catalog and write a text
' file containing all artists and albums with statistics.
' Essentially this script simply list directories with subdirectories to a specific depth.
' Script expect the following path structure: TopFolder\A\Artist\Year - Album
' please see end of this file for detailed specifications
'
' Known issues:
' There are no feedback while script run other than the dialog at the end when script finish.
'
' Last folder will not have statistic for artist and album count.
' Now only owning a single CD where artist name start with the
' Norwegian letter 'Ø' I'm not in a hurry to fix this :)
'
Dim TabString, LEVEL, C2, C3, CT2, CT3, COUNTER, mFileName, mSF
' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
' SET PATH TO MUSIC COLLECTION:
'
' Top directory for music collection, including full path to network drive if used
objStartFolder = "\\OMV-LMS\wav"
' NOTE: Not specifying path the report is written to directory from where script is run
mFileName = "Music Collection " & Replace(Date,".","-") & " [" & Replace(Time,":","") & "].txt"'
' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(mFileName) Then _
objFSO.DeleteFile mFileName
Set objTxtFile = objFSO.CreateTextFile(mFileName, ForWriting, False) ' True = Unicode, False = ASCII
Set objFolder = objFSO.GetFolder(objStartFolder)
TabString = ""
COUNTER = 0
LEVEL = 0
mRet = MsgBox ("Do you want to scan " & objFolder.Path, 36, "Scan music folder?")
If mRet = 7 Then WScript.Quit 0 'End here if user abort
objTxtFile.WriteLine "Music Collection " & Date & "-" & Time & " " & objStartFolder
' NOTE - If text file are to be html taged it also will need each line to end with '
'
' objTxtFile.WriteLine "
Music Collection"
' Call the loop function creating the report
ListSubfolders objFSO.GetFolder(objStartFolder)
' Write end of report
objTxtFile.WriteBlankLines(1)
objTxtFile.WriteLine Date & "-" & Time & " Total artists count: " & CT2 & " totaL album count: " & CT3
' objTxtFile.WriteLine ""
objTxtFile.Close
Set objFSO = Nothing
mMsg = "Finished! " & Chr(10) & Chr(10) _
& "Total artists count: " & CT2 & Chr(10) _
& "Total album count: " & CT3 & Chr(10) & Chr(10) _
& "Collection report saved to file " & Chr(10) _
& mFileName & Chr(10) & Chr(10) _
& "Script by http://snw.lonningdal.no" _
& Chr(10) & "VBScript Version: " _
& ScriptEngineMajorVersion _
& "." & ScriptEngineMinorVersion
mRet = MsgBox (mMsg & Chr(10) & Chr(10) & "Do you want to open " & mFileName, 36, "Open report?")
If mRet = 6 Then
Set WshShell = WScript.CreateObject("WScript.Shell")
'WshShell.Run "%windir%\notepad " & WScript.ScriptFullName
mOpen = WshShell.Run ("%windir%\notepad " & WshShell.CurrentDirectory & "\" & mFileName, 3)
Set WshShell = Nothing
End If
WScript.Quit 0
Sub ListSubFolders(Folder)
COUNTER = COUNTER +1
If LEVEL > 1 Then TabString = TabString & " "
LEVEL = LEVEL + 1
For Each Subfolder in Folder.SubFolders
Select Case LEVEL
Case 1
objTxtFile.WriteBlankLines(1)
If C2=1 Then txtAR=" artist" else txtAR=" artists"
If C3=1 Then txtAL=" album" else txtAL=" albums"
If COUNTER > 1 Then objTxtFile.Write "There are " & C2 & txtAR & " registered with " & C3 & txtAL & " under '" & mSF & "'"
objTxtFile.WriteBlankLines(2)
CT2 = CT2 + C2
CT3 = CT3 + C3
C2 = 0
C3 = 0
'objTxtFile.Write "[ " & UCase(Subfolder.Name) & " ] **************************************************"
objTxtFile.Write "[ " & UCase(Subfolder.Name) & " ] --------------------------------------------------"
mSF = UCase(Subfolder.Name)
Case 2
C2 = C2 +1
objTxtFile.Write TabString & Subfolder.Name
Case 3
C3 = C3 +1
objTxtFile.Write TabString & Subfolder.Name
Case Else
objTxtFile.Write TabString & Subfolder.Name
End Select
objTxtFile.WriteBlankLines(1)
ListSubFolders Subfolder
' For test purpose
'If COUNTER = 200 Then Exit Sub
Next
LEVEL = LEVEL - 1
If Len(TabString) => 2 Then TabString = Left(TabString, Len(TabString)-2)
End Sub
' This is how I a ended up structure my music collection
' after several attempts to make it in order for use with
' multiple platforms and archive systems. With the main
' benefit that the use of raw wav files with no tags are
' still given some useful context when browsing file directoris.
'
' \Top directory named as file extention i.e. 'wav' or 'flac'
' \Alphabet (all letters listed) with special directories for
' '#' numeric band names, and then special folders like
' Classical, Children, Christmas, Compilation CD's with mixed artists
' \Artist Name, sortet by last name where artist 'Ben Arnold' are stored in directory 'A'
' \AlbumYear - Album Name
' Directory name for Album always start with 'year - ' (four digits)
' If album year are uknown a dummy number like 1000 are used
' Album folder holds music files beginning with song number 01 - songname,
' Double album are stored in single folder with three digits song number where first digit are CD# 101 - , 201 -, 301 - etc.
' Album folder also holds album cover consistently named "folder.jpg",
' log file if ripping error occurred, other cover art, other related notes and text files
'
' CD with various artis are stored as albums where song name are written as:
' "wav\Various\Edel Records\2000 - Party Zone 2000\115 - Larger Than Life - Backstreet Boys.wav"
' then there are a folder "vaw\Various\1000 - Various Artists\001 - Large - Boys.wav" for songs not associated with an album
'
' I use EAC http://exactaudiocopy.de/ which beside accurate data extraction
' also makes for easy song numbering and file naming