Option Explicit Const ForAppending = 8 Const ForReading = 1 Const ForWriting = 2 Dim gvbForceOverwrite, gvbInteractive, gvbLanguageFile, gvbMyMusic Dim gvdMessages Dim gvbRetry, gvbQuiet Dim i, intAnswer, intButtons, intFirstTrack, intLastTrack, intTracks, gviCDROMDrives, gviAudioCDsLoaded, intValidArgs Dim gvoAudioCDsList, gvoCDROMDrivesList, gvoConfigFile, objFile, gvoFSO, gvoWMIService, wshShell Dim gvsCDROMDrive, gvsDrives, gvsTargetFolder, gvsVLCPath, strFile, strFileList, strMessage, strTitle, strPrefCDROM, gvsLanguage, gvsProgVer gvsProgVer = "1.00" Set wshShell = CreateObject( "WScript.Shell" ) Set gvoFSO = CreateObject( "Scripting.FileSystemObject" ) Set gvoCDROMDrivesList = CreateObject( "System.Collections.ArrayList" ) Set gvoAudioCDsList = CreateObject( "System.Collections.ArrayList" ) Set gvoWMIService = GetObject( "winmgmts://./root/CIMV2" ) Set gvdMessages = CreateObject( "Scripting.Dictionary" ) With WScript.Arguments.Named intValidArgs = 0 If .Exists( "L" ) Then ' Use translated or customized messages gvbLanguageFile = True gvsLanguage = .Item( "L" ) intValidArgs = intValidArgs + 1 Else gvbLanguageFile = False End If GetMessages ' Get a list of default error and status messages, and replace them by translated or customized messages if applicable If .Exists( "F" ) Then ' Overwrite existing MP3 files in the target folder without prompt for confirmation gvbForceOverwrite = True intValidArgs = intValidArgs + 1 Else gvbForceOverwrite = False End If If .Exists( "I" ) Then ' Interactive mode: prompt for anything not specified on the command line gvbInteractive = True intValidArgs = intValidArgs + 1 If .Exists( "M" ) Then gvbMyMusic = True intValidArgs = intValidArgs + 1 Else gvbMyMusic = False End If Else gvbInteractive = False End If If .Exists( "Q" ) Then ' Quiet mode: no status messages on screen, error messages only gvbQuiet = True intValidArgs = intValidArgs + 1 Else gvbQuiet = False End If If .Exists( "?" ) Then Syntax "" If intValidArgs <> .Count Then Syntax gvdMessages.Item( "InvalidSwitches" ) End With With WScript.Arguments.Unnamed Select Case .Count Case 0 ' No "unnamed" arguments only allowed in interactive mode If gvbInteractive Then ' Prompt for target folder If gvbMyMusic Then gvsTargetFolder = BrowseFolder( gvdMessages.Item( "SelectTargetFolder" ), wshShell.RegRead( "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\My Music" ) ) Else gvsTargetFolder = BrowseFolder( gvdMessages.Item( "SelectTargetFolder" ), wshShell.SpecialFolders( "DESKTOP" ) ) End If ' Abort if "Cancel" button was clicked If IsNull( gvsTargetFolder ) Then WScript.Echo vbCrLf & gvdMessages.Item( "Aborting" ) & " . . ." AbortScript 1 End If Else Syntax "" End If Case 1 ' First "unnamed" argument is the target folder gvsTargetFolder = .Item(0) Case 2 ' First "unnamed" argument is the target folder, second is the CDROM drive to read gvsTargetFolder = .Item(0) strPrefCDROM = UCase( .Item(1) ) Case Else ' There is no case where more than 2 "unnamed" arguments are valid Syntax gvdMessages.Item( "InvalidArgs" ) End Select End With ' Create target folder if necessary If Not MakeDir( gvsTargetFolder ) Then ' Target folder does not exist and creating it failed If gvbInteractive Then ' Prompt for a retry in interactive mode ' Ask if the user wants to try again strTitle = gvdmessages.Item( "AlternateTarget" ) intButtons = vbYesNoCancel + vbQuestion + vbApplicationModal strMessage = gvdMessages.Item( "MakeDirError" ) If Not IsNull( gvsTargetFolder ) Then strMessage = strMessage & " """ & gvsTargetFolder & """" strMessage = strMessage & vbCrLf & vbCrLf & gvdMessages.Item( "AlternatePrompt" ) intAnswer = MsgBox( strMessage, intButtons, strTitle ) If intAnswer = vbYes Then ' User wants to try a different target folder ' Prompt for alternate target folder If gvbMyMusic Then ' /M switch was used to start browsing in "My Music" gvsTargetFolder = BrowseFolder( gvdMessages.Item( "AlternateTarget" ), wshShell.RegRead( "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\My Music" ) ) Else ' /M not used, start browsing in "Desktop" gvsTargetFolder = BrowseFolder( gvdMessages.Item( "AlternateTarget" ), wshShell.SpecialFolders( "DESKTOP" ) ) End If If IsNull( gvsTargetFolder ) Then ' Cancel button was clicked WScript.Echo vbCrLf & gvdMessages.Item( "Aborting" ) & " . . ." AbortScript 1 End If If Not MakeDir( gvsTargetFolder ) Then ' Alternate target folder does not exist and creating it failed Syntax Replace( gvdMessages.Item( "MakeDirError" ), "%1", gvsTargetFolder ) End If Else ' User gave up after first MakeDir error WScript.Echo vbCrLf & gvdMessages.Item( "Aborting" ) & " . . ." AbortScript 1 End If Else ' Abort unless in interactive mode Syntax Replace( gvdMessages.Item( "MakeDirError" ), "%1", gvsTargetFolder ) End If End If ' Check for existing Track*.mp3 files ik the target folder strFileList = "" intTracks = 0 ' Total number of tracks found intFirstTrack = 10000 ' Lowest track index number found so far intLastTrack = 0 ' Highest track index number found so far With gvoFSO For Each objFile In .GetFolder( gvsTargetFolder ).Files strFile = objFile.Name If LCase( .GetExtensionName( strFile ) ) = "mp3" Then If Left( LCase( .GetBaseName( strFile ) ), 5 ) = "track" Then If IsNumeric( Mid( .GetBaseName( strFile ), 6 ) ) Then intFirstTrack = Min( intFirstTrack, CInt( Mid( .GetBaseName( strFile ), 6 ) ) ) intLastTrack = Max( intLastTrack, CInt( Mid( .GetBaseName( strFile ), 6 ) ) ) intTracks = intTracks + 1 strFileList = strFileList & ", """ & .GetFileName( strFile ) & """" End If End If End If Next End With ' Display as range if possible, e.g. "Track1.mp3 .. Track4.mp3" instead of "Track1.mp3, Track2.mp3, Track3.mp3, Track4.mp3" If intLastTrack - intFirstTrack + 1 = intTracks And intTracks > 2 Then strFileList = "Track" & intFirstTrack & ".mp3 .. Track" & intLastTrack & ".mp3" Else ' Remove leading comma and space strFileList = Mid( strFileList, 3 ) End If Select Case intTracks Case 0 strMessage = Replace( Replace( gvdMessages.Item( "FilesInTargetFolder" ), "%1", gvdMessages.Item( "ZeroNo" ) ), "%2", "s" ) Case 1 strMessage = gvdMessages.Item( "FileInTargetFolder" ) & ": " & strFileList Case Else strMessage = Replace( Replace( gvdMessages.Item( "FilesInTargetFolder" ), "%1", intTracks ), "%2", "s" ) & ": " & strFileList End Select If gvbInteractive Then If intTracks > 0 Then ' Prompt for confirmation to overwrite existing MP3 files in target folder If intTracks = 1 Then strMessage = strMessage & vbCrLf & vbCrLf & gvdMessages.Item( "OverwritePrompt1" ) Else strMessage = strMessage & vbCrLf & vbCrLf & gvdMessages.Item( "OverwritePromptMulti" ) End If intButtons = vbYesNoCancel + vbQuestion + vbApplicationModal strTitle = gvdMessages.Item( "OverwritePromptTitle" ) intAnswer = MsgBox( strMessage, intButtons, strTitle ) If intAnswer = vbYes Then WScript.Echo gvdMessages.Item( "Overwriting" ) & " . . ." gvbForceOverwrite = True Else WScript.Echo vbCrLf & gvdMessages.Item( "Aborting" ) & " . . ." AbortScript 1 End If End If Else If intTracks > 0 Or Not gvbQuiet Then WScript.Echo strMessage End If If intTracks > 0 And Not gvbForceOverwrite Then ' Existing tracks were found in target folder and overwrite is not allowed WScript.Echo vbCrLf & gvdMessages.Item( "Aborting" ) & " . . ." AbortScript 1 End If ' List all CDROM drives If Not GetCDROMDrivesList( ) Then ' Abort if no CDROM drive is found WScript.Echo vbCrLf & gvdMessages.Item( "Aborting" ) & " . . ." AbortScript 1 End If ' Check which one contains an audio CD Do If Not GetAudioCDDrive( strPrefCDROM ) Then AbortScript 1 ' Abort if Abort button is clicked Loop While gvbRetry ' Retry if no audio CD or multiple audio CDs are found and Retry is clicked ' Get path of VLC executable On Error Resume Next gvsVLCPath = wshShell.RegRead( "HKEY_LOCAL_MACHINE\SOFTWARE\VideoLAN\VLC\" ) On Error Goto 0 If gvsVLCPath = "" Then strMessage = gvdMessages.Item( "VLCNotFoundText" ) strTitle = gvdMessages.Item( "VLCNotFoundTitle" ) intButtons = vbYesNoCancel + vbInformation + vbApplicationModal intAnswer = MsgBox( strMessage, intButtons, strTitle ) If intAnswer = vbYes Then wshShell.Run "http://www.videolan.org/", 3, False End If AbortScript 1 End If strMessage = gvdMessages.Item( "ReadingFromCDROM" ) & " " & gvsCDROMDrive & vbCrLf _ & gvdMessages.Item( "ExportingToFolder" ) & " """ & gvsTargetFolder & """" If Not gvbQuiet Then WScript.Echo strMessage ' Run export command for each track on the audio CD For Each objFile In gvoFSO.GetDrive( gvsCDROMDrive ).RootFolder.Files ExtractTrack objFile.Name Next ' Done AbortScript 0 Function BrowseFolder( strPrompt, strDefaultFolder ) Dim objFolder, objShell Const BIF_RETURNONLYFSDIRS = 1 ' Only return file system directories. If the user selects folders that are not part of the file system, the OK button is grayed. The OK button remains enabled for UNC items. Const BIF_DONTGOBELOWDOMAIN = 2 ' Do not include network folders below the domain level in the dialog box's tree view control. Const BIF_STATUSTEXT = 4 ' Include a status area in the dialog box. The callback function can set the status text by sending messages to the dialog box. This flag is not supported when BIF_NEWDIALOGSTYLE is specified. Const BIF_RETURNFSANCESTORS = 8 ' Only return file system ancestors. An ancestor is a subfolder that is beneath the root folder in the namespace hierarchy. If the user selects an ancestor of the root folder that is not part of the file system, the OK button is grayed. Const BIF_EDITBOX = 16 ' Include an edit control in the browse dialog box that allows the user to type the name of an item. Const BIF_VALIDATE = 32 ' If the user types an invalid name into the edit box, the browse dialog box calls the application's BrowseCallbackProc with the BFFM_VALIDATEFAILED message. This flag is ignored if BIF_EDITBOX is not specified. Const BIF_NEWDIALOGSTYLE = 64 ' Use the new user interface. Setting this flag provides the user with a larger dialog box that can be resized. The dialog box has several new capabilities, including: drag-and-drop capability within the dialog box, reordering, shortcut menus, new folders, delete, and other shortcut menu commands. Const BIF_USENEWUI = 80 ' Use the new user interface, including an edit box. This flag is equivalent to BIF_EDITBOX | BIF_NEWDIALOGSTYLE. Const BIF_BROWSEINCLUDEURLS = 128 ' The browse dialog box can display URLs. The BIF_USENEWUI and BIF_BROWSEINCLUDEFILES flags must also be set. If any of these three flags are not set, the browser dialog box rejects URLs. Even when these flags are set, the browse dialog box displays URLs only if the folder that contains the selected item supports URLs. When the folder's IShellFolder::GetAttributesOf method is called to request the selected item's attributes, the folder must set the SFGAO_FOLDER attribute flag. Otherwise, the browse dialog box will not display the URL. Const BIF_UAHINT = 256 ' When combined with BIF_NEWDIALOGSTYLE, adds a usage hint to the dialog box, in place of the edit box. BIF_EDITBOX overrides this flag. Const BIF_NONEWFOLDERBUTTON = 512 ' Do not include the New Folder button in the browse dialog box. Const BIF_NOTRANSLATETARGETS = 1024 ' When the selected item is a shortcut, return the PIDL of the shortcut itself rather than its target. Const BIF_BROWSEFORCOMPUTER = 4096 ' Only return computers. If the user selects anything other than a computer, the OK button is grayed. Const BIF_BROWSEFORPRINTER = 8192 ' Only allow the selection of printers. If the user selects anything other than a printer, the OK button is grayed. In Windows XP and later systems, the best practice is to use a Windows XP-style dialog, setting the root of the dialog to the Printers and Faxes folder (CSIDL_PRINTERS). Const BIF_BROWSEINCLUDEFILES = 16384 ' The browse dialog box displays files as well as folders. Const BIF_SHAREABLE = 32768 ' The browse dialog box can display sharable resources on remote systems. This is intended for applications that want to expose remote shares on a local system. The BIF_NEWDIALOGSTYLE flag must also be set. Const BIF_BROWSEFILEJUNCTIONS = 65536 ' Windows 7 and later. Allow folder junctions such as a library or a compressed file with a .zip file name extension to be browsed. BrowseFolder = Null On Error Resume Next Set objShell = CreateObject( "Shell.Application" ) Set objFolder = objShell.BrowseForFolder( 0, strPrompt, BIF_RETURNONLYFSDIRS + BIF_RETURNFSANCESTORS + BIF_VALIDATE + BIF_NEWDIALOGSTYLE, strDefaultFolder ) If IsObject( objFolder ) Then BrowseFolder = objFolder.Self.Path Set objFolder = Nothing Set objshell = Nothing On Error Goto 0 End Function Sub ExtractTrack( strTrack ) Dim intTrack, strMessage, strMP3, strVLCCommand intTrack = Right( gvoFSO.GetBaseName( strTrack ), 3 ) If Not IsNumeric( intTrack ) Then intTrack = Right( gvoFSO.GetBaseName( strTrack ), 2 ) If Not IsNumeric( intTrack ) Then intTrack = Right( gvoFSO.GetBaseName( strTrack ), 1 ) If Not IsNumeric( intTrack ) Then WScript.Echo vbCrLf & gvdMessages.Item( "SkippedUnknown" ) & ": """ & strTrack & """" Exit Sub End If intTrack = CInt( intTrack ) With gvoFSO strMP3 = .BuildPath( gvsTargetFolder, .GetBaseName( strTrack ) & ".mp3" ) strVLCCommand = """" & gvsVLCPath & """ -I http cdda:///" & gvsCDROMDrive & "/ --cdda-track=" & intTrack & " :sout=#transcode{vcodec=none,acodec=mp3,ab=128,channels=2,samplerate=44100}:std{access=""file"",mux=raw,dst=""" & strMP3 & """} vlc://quit" strMessage = vbCrLf _ & gvdMessages.Item( "Transcoding" ) & " " & strTrack & vbCrLf _ & gvdMessages.Item( "OutputTo" ) & " """ & strMP3 & """" & vbCrLf _ & gvdMessages.Item( "Exporting" ) & " . . ." '& vbCrLf & strVLCCommand If Not gvbQuiet Then WScript.Echo strMessage wshShell.Run strVLCCommand, 7, True End With End Sub ' Detect CDROM drives and audio CDs. ' Return true if only 1 audio CD is loaded, and store the drive letter. Function GetAudioCDDrive( strDrive ) GetAudioCDDrive = True Dim i, intAnswer, intButtons Dim colItems, objItem Dim strAudioCDs, strMessage, strQuery, strTitle gvbRetry = False strQuery = "SELECT * FROM Win32_CDROMDrive WHERE MediaLoaded=True AND VolumeName LIKE 'Audio%'" If Not strDrive = "" Then strQuery = strQuery & " AND Drive='" & UCase( strDrive ) & "'" Set colItems = gvoWMIService.ExecQuery( strQuery ) gviAudioCDsLoaded = colItems.Count Select Case gviAudioCDsLoaded Case 0 If strDrive = "" Then strMessage = gvdMessages.Item( "NoAudioCDText1" ) If gviCDROMDrives > 1 Then strMessage = Replace( strMessage, "%1", Replace( gvdMessages.Item( "NoAudioCDText2" ), "%1", gvsDrives ) ) ' gvsDrives is set in GetCDROMDrivesList( ) Else strMessage = Replace( strMessage, "%1", "" ) End If Else strMessage = Replace( gvdMessages.Item( "NoAudioDriveSpecText" ), "%1", UCase( strDrive ) ) End If strMessage = Replace( strMessage, "\n", vbCrLf ) strTitle = gvdMessages.Item( "NoAudioCDTitle" ) intButtons = vbRetryCancel + vbInformation + vbApplicationModal intAnswer = MsgBox( strMessage, intButtons, strTitle ) If intAnswer = vbRetry Then gvbRetry = True Else GetAudioCDDrive = False End If Case 1 For Each objItem In colItems gvsCDROMDrive = objItem.Drive Next Case Else For Each objItem In colItems gvoAudioCDsList.Add objItem.Drive Next strAudioCDs = gvoAudioCDsList.Item(0) For i = 1 To gviAudioCDsLoaded - 1 If i = gviAudioCDsLoaded - 1 Then strAudioCDs = strAudioCDs & " or " & gvoAudioCDsList.Item(i) Else strAudioCDs = strAudioCDs & ", " & gvoAudioCDsList.Item(i) End If Next strMessage = gvdMessages.Item( "MultipleAudioCDsText" ) strTitle = gvdMessages.Item( "MultipleAudioCDsTitle" ) intButtons = vbRetryCancel + vbInformation + vbApplicationModal intAnswer = MsgBox( strMessage, intButtons, strTitle ) If intAnswer = vbRetry Then gvbRetry = True Else GetAudioCDDrive = False End If End Select Set colItems = Nothing End Function ' Get CDROM drive letter(s), return False if none found Function GetCDROMDrivesList( ) GetCDROMDrivesList = True Dim intButtons, intTracks Dim colItems, objItem Dim strDrive, strMessage, strQuery, strTitle strQuery = "SELECT * FROM Win32_CDROMDrive" Set colItems = gvoWMIService.ExecQuery( strQuery ) gviCDROMDrives = colItems.Count For Each objItem In colItems strDrive = objItem.Drive strMessage = strMessage & Replace( gvdMessages.Item( "FoundCDROMDrive" ), "%1", strDrive ) gvoCDROMDrivesList.Add strDrive If LCase( Left( objItem.VolumeName, 5 ) ) = "audio" Then strMessage = Replace( strMessage, "%2", gvdMessages.Item( "AudioCDLoadedYes" ) ) & vbCrLf intTracks = gvoFSO.GetFolder( strDrive & "\" ).Files.Count If intTracks = 1 Then strMessage = Replace( strMessage, "%3", ", 1 " & gvdMessages.Item( "Track" ) ) Else strMessage = Replace( strMessage, "%3", ", " & intTracks & " " & gvdMessages.Item( "Tracks" ) ) End If Else strMessage = Replace( Replace( strMessage, "%2", gvdMessages.Item( "AudioCDLoadedNo" ) ), "%3", "" ) & vbCrLf End If Next If Not gvbQuiet Then WScript.Echo strMessage gvoCDROMDrivesList.Sort gvsDrives = "" Select Case gviCDROMDrives Case 0 strMessage = gvdMessages.Item( "NoCDROMDriveText" ) strTitle = gvdMessages.Item( "NoCDROMDriveTitle" ) intButtons = vbOKOnly + vbExclamation + vbApplicationModal MsgBox strMessage, intButtons, strTitle GetCDROMDrivesList = False Case 1 gvsDrives = gvoCDROMDrivesList.Item(0) Case Else gvsDrives = gvoCDROMDrivesList.Item(0) For i = 1 To gviCDROMDrives - 1 If i = gviCDROMDrives - 1 Then gvsDrives = gvsDrives & " " & gvdMessages.Item( "or" ) & " " & gvoCDROMDrivesList.Item(i) Else gvsDrives = gvsDrives & ", " & gvoCDROMDrivesList.Item(i) End If Next End Select Set colItems = Nothing End Function ' Get a list of default error and status messages, and replace them by translated messages if applicable Sub GetMessages( ) Dim strConfigFile, strConfigText, strKey, strLine, strVal gvdMessages.Item( "Aborting" ) = "Aborting" gvdMessages.Item( "AlternatePrompt" ) = "Do you want to specify an alternative target folder?" gvdMessages.Item( "AlternateTarget" ) = "Please select/create an alternative target folder" gvdMessages.Item( "AudioCDLoadedNo" ) = "no" gvdMessages.Item( "AudioCDLoadedYes" ) = "with" gvdMessages.Item( "CreatingFolder" ) = "Creating folder: ""%1""" gvdMessages.Item( "CustomFileNotFound" ) = "Custom messages file not found" gvdMessages.Item( "Error" ) = "ERROR" gvdMessages.Item( "Exporting" ) = "Exporting" gvdMessages.Item( "ExportingToFolder" ) = "Exporting to output folder" gvdMessages.Item( "FileInTargetFolder" ) = "Found a file in target folder" gvdMessages.Item( "FilesInTargetFolder" ) = "Found %1 file%2 in target folder" gvdMessages.Item( "FoundCDROMDrive" ) = "Found CDROM drive %1 (%2 audio CD loaded%3)" gvdMessages.Item( "InvalidArgs" ) = "Invalid command line arguments." gvdMessages.Item( "InvalidSwitches" ) = "Invalid or duplicate command line switches." gvdMessages.Item( "MakeDirError" ) = "Unable to create target folder" gvdMessages.Item( "MultipleAudioCDsText" ) = "The script found multiple CDROM drives with an audio CD inserted.\n\nEither specify the CDROM drive on the command line, or remove all audio CDs but one and click Retry to try again." gvdMessages.Item( "MultipleAudioCDsTitle" ) = "Multiple Audio CDs" gvdMessages.Item( "NoAudioCDText1" ) = "The script was unable to locate a CDROM drive with an audio CD inserted.\n\nPlease insert an audio CD%1 and click Retry to try again." gvdMessages.Item( "NoAudioCDText2" ) = " in one of the CDROM drives (%1)" gvdMessages.Item( "NoAudioDriveSpecText" ) = "No audio CD found in the specified CDROM drive (%1)\n\nPlease insert an audio CD in CDROM drive %1 and click Retry to try again." gvdMessages.Item( "NoAudioCDTitle" ) = "No Audio CD" gvdMessages.Item( "NoCDROMDriveText" ) = "The script was unable to locate a CDROM drive.\n\nPlease specify a CDROM drive on the command line." gvdMessages.Item( "NoCDROMDriveTitle" ) = "No CDROM Drive" gvdMessages.Item( "or" ) = "or" gvdMessages.Item( "OutputTo" ) = "Output to" gvdMessages.Item( "OverwritePrompt1" ) = "Do you want to overwrite it?" gvdMessages.Item( "OverwritePromptMulti" ) = "Do you want to overwrite them?" gvdMessages.Item( "OverwritePromptTitle" ) = "Overwrite Files?" gvdMessages.Item( "Overwriting" ) = "Overwriting files" gvdMessages.Item( "ReadingFromCDROM" ) = "Reading from CDROM drive" gvdMessages.Item( "SelectTargetFolder" ) = "Select a target folder" gvdMessages.Item( "SkippedUnknown" ) = "Skipped unknown content" gvdMessages.Item( "Track" ) = "track" gvdMessages.Item( "Tracks" ) = "tracks" gvdMessages.Item( "Transcoding" ) = "Transcoding" gvdMessages.Item( "VLCNotFoundText" ) = "The script could not find a VLC Media Player installation.\n\nVLC Media Player is required for this script.\n\nDo you want to open the VLC download page in your browser?" gvdMessages.Item( "VLCNotFoundTitle" ) = "VLC Not Found" gvdMessages.Item( "ZeroNo" ) = "no" ' Help Text lines gvdMessages.Item( "SyntaxTitleLine" ) = "RipCD.vbs, Version %1" gvdMessages.Item( "SyntaxDescrLine" ) = "Save audio CD tracks as MP3s" gvdMessages.Item( "SyntaxUsageLine" ) = "Usage: RIPCD.VBS targetfolder [drive:] [/F] [/I [/M]] [/L:lang] [/Q]" gvdMessages.Item( "SyntaxWhereTarget" ) = "Where: ""targetfolder"" is the fully qualified path to the folder where the\nMP3s are to be stored" gvdMessages.Item( "SyntaxWhereDrive" ) = "drive: is the CDROM drive letter where the audio CD is located" gvdMessages.Item( "SyntaxWhereSwF" ) = "/F Force overwrite of existing files in the target folder" gvdMessages.Item( "SyntaxWhereSwI" ) = "/I Interactive mode: prompt for input when necessary" gvdMessages.Item( "SyntaxWhereSwL" ) = "/L[:lang] use translated or custom messages (see note 3 below)" gvdMessages.Item( "SyntaxWhereSwM" ) = "/M suggest ""My Music"" or subfolders only as targetfolder\nwhen in Interactive mode (requires /I)" gvdMessages.Item( "SyntaxWhereSwQ" ) = "/Q Quiet mode: less screen output (errors only)" gvdMessages.Item( "SyntaxNotes1" ) = "Notes: 1 This script requires VLC Media Player; if it isn't found, you will\nbe prompted to open the VLC download page in your default web browser." gvdMessages.Item( "SyntaxNotes2" ) = "2 By default, the script will abort if ""Track*.mp3"" files are detected\nin the target folder. Use /F to overwrite without confirmation." gvdMessages.Item( "SyntaxNotes3" ) = "3 The default messages can be replaced by translated or custom messages;\nto do so, run the script with the /L switch (no value) to create a\ntemplate file ""RipCD.en"". Open that file in a text editor, modify\nthe messages you want to change or translate, and save the file with\na different extension (e.g. ""ripcd.NL"" for a Dutch translation).\nTo use the modified messages, run the script with /L:extension\n(e.g. /L:NL for a Dutch translation located in ""ripcd.NL"")." gvdMessages.Item( "SyntaxCredits" ) = "Credits: Main functionality by elrobis (http://cartometric.com/blog/2015/03/07)\nAutomatic CDROM drive and VLC path detection by Rob van der Woude" gvdMessages.Item( "SyntaxAuthor" ) = "Written by Rob van der Woude\nhttp://www.robvanderwoude.com" If gvbLanguageFile Then With gvoFSO If gvsLanguage = "" Then ' Write current messages to a "template" file strConfigFile = .BuildPath( .GetParentFolderName( WScript.ScriptFullName ), .GetBaseName( WScript.ScriptName ) & ".en" ) Set gvoConfigFile = .OpenTextFile( strConfigFile, ForWriting, True ) gvoConfigFile.WriteLine "// Do not replace or translate %1 .. %3, these are ""placeholders"" for variables in messages" For Each strKey In gvdMessages.Keys strVal = gvdMessages.Item( strKey ) strLine = strKey & "=" & strVal gvoConfigFile.WriteLine strLine Next gvoConfigFile.Close Else ' Read translated or custom messages from text file strConfigFile = .BuildPath( .GetParentFolderName( WScript.ScriptFullName ), .GetBaseName( WScript.ScriptName ) & "." & gvsLanguage ) If .FileExists( strConfigFile ) Then Set gvoConfigFile = .OpenTextFile( strConfigFile, ForReading, False ) strConfigText = gvoConfigFile.ReadAll( ) For Each strLine In Split( strConfigText, vbCrLf ) If InStr( strLine, "=" ) Then strKey = Left( strLine, InStr( strLine, "=" ) - 1 ) strVal = Mid( strLine, InStr( strLine, "=" ) + 1 ) gvdMessages.Item( strKey ) = strVal End If Next Else Syntax gvdMessages.Item( "CustomFileNotFound" ) & ": """ & strConfigFile & """" End If End If Set gvoConfigFile = Nothing End With End If End Sub Function MakeDir( strFolder ) MakeDir = False On Error Resume Next Dim gvoFSO, strFullPath, strLeft, strNextFolder, strRoot, strTreeSoFar Set gvoFSO = CreateObject( "Scripting.FileSystemObject" ) strFullPath = gvoFSO.GetAbsolutePathName( gvsTargetFolder ) strRoot = gvoFSO.GetDriveName( gvsTargetFolder ) If Len( strRoot ) = 2 Then strLeft = Mid( strFullPath, Len( strRoot ) + 2 ) strTreeSoFar = strRoot For Each strNextFolder In Split( strLeft, "\" ) strTreeSoFar = gvoFSO.BuildPath( strTreeSoFar & "\", strNextFolder ) If Not gvoFSO.FolderExists( strTreeSoFar ) Then If Not gvbQuiet Then WScript.Echo Replace( gvdMessages.Item( "CreatingFolder" ), "%1", strTreeSoFar ) gvoFSO.CreateFolder( strTreeSoFar ) End If Next MakeDir = gvoFSO.FolderExists( strFullPath ) End If Set gvoFSO = Nothing On Error Goto 0 End Function Function Max( num1, num2 ) If num1 > num2 Then Max = num1 Else Max = num2 End If End Function Function Min( num1, num2 ) If num1 < num2 Then Min = num1 Else Min = num2 End If End Function Sub Syntax( errMsg ) Dim strMsg strMsg = vbCrLf If Not errMsg = "" Then strMsg = strMsg & gvdMessages.Item( "Error" ) & ": " & errMsg & vbCrLf & vbCrLf strMsg = strMsg _ & Replace( Replace( gvdMessages.Item( "SyntaxTitleLine" ), "\n", vbCrLf ), "%1", gvsProgVer ) & vbCrLf _ & Replace( gvdMessages.Item( "SyntaxDescrLine" ), "\n", vbCrLf ) & vbCrLf & vbCrLf _ & Replace( gvdMessages.Item( "SyntaxUsageLine" ), "\n", vbCrLf & Space( 9 ) ) & vbCrLf & vbCrLf _ & Replace( gvdMessages.Item( "SyntaxWhereTarget" ), "\n", vbCrLf & Space( 25 ) ) & vbCrLf _ & Space( 9 ) & Replace( gvdMessages.Item( "SyntaxWhereDrive" ), "\n", vbCrLf & Space( 25 ) ) & vbCrLf _ & Space( 9 ) & Replace( gvdMessages.Item( "SyntaxWhereSwF" ), "\n", vbCrLf & Space( 25 ) ) & vbCrLf _ & Space( 9 ) & Replace( gvdMessages.Item( "SyntaxWhereSwI" ), "\n", vbCrLf & Space( 25 ) ) & vbCrLf _ & Space( 9 ) & Replace( gvdMessages.Item( "SyntaxWhereSwL" ), "\n", vbCrLf & Space( 25 ) ) & vbCrLf _ & Space( 9 ) & Replace( gvdMessages.Item( "SyntaxWhereSwM" ), "\n", vbCrLf & Space( 25 ) ) & vbCrLf _ & Space( 9 ) & Replace( gvdMessages.Item( "SyntaxWhereSwQ" ), "\n", vbCrLf & Space( 25 ) ) & vbCrLf & vbCrLf _ & Replace( gvdMessages.Item( "SyntaxNotes1" ), "\n", vbCrLf & Space( 9 ) ) & vbCrLf _ & Space( 7 ) & Replace( gvdMessages.Item( "SyntaxNotes2" ), "\n", vbCrLf & Space( 9 ) ) & vbCrLf _ & Space( 7 ) & Replace( gvdMessages.Item( "SyntaxNotes3" ), "\n", vbCrLf & Space( 9 ) ) & vbCrLf & vbCrLf _ & Replace( gvdMessages.Item( "SyntaxCredits" ), "\n", vbCrLf & Space( 9 ) ) & vbCrLf & vbCrLf _ & Replace( gvdMessages.Item( "SyntaxAuthor" ), "\n", vbCrLf ) WScript.Echo strMsg AbortScript 1 End Sub ' Abort the script after cleaning up any leftover objects Sub AbortScript( intRC ) On Error Resume Next Set gvdMessages = Nothing Set gvoWMIService = Nothing Set gvoAudioCDsList = Nothing Set gvoCDROMDrivesList = Nothing Set gvoConfigFile = Nothing Set gvoFSO = Nothing Set wshShell = Nothing On Error Goto 0 WScript.Quit intRC End Sub