Code: Select all
@ECHO OFF
REM This batch file allows you to rip all tracks from an audio CD to MP3 or WAV.
REM However, it must be adapted to the individual circumstances.
REM ***** enter after "CD " the installation directory of vlc.exe *****
CD C:\Program Files (x86)\VideoLAN\VLC\
REM ***** enter after "SET s=" the source directory for the optical drive *****
SET s=O:\
REM ***** enter after "SET p=" the destination directory for ribbed tracks *****
SET p=D:\Musik\
REM ***** enter after "SET m=" for conversion to MP3 > "MP3", to WAV > "WAV" *****
SET m=MP3
SETLOCAL ENABLEDELAYEDEXPANSION
SET /a n=0
SET f=""
FOR /R %s% %%L IN (*.cda) DO (CALL :sub_transcode "%%L")
GOTO :eof
:sub_transcode
Call SET /a n=n+1
ECHO Transcoding %1
IF !n! LEQ 9 (GOTO :with_zero) ELSE (GOTO :without_zero)
:with_zero
CALL SET f=%p%Track_0!n!.mp3
GOTO :transcode
:without_zero
CALL SET f=%p%Track_!n!.mp3
:transcode
if /i %m%==MP3 (
CALL vlc -I http cdda:///%s% --cdda-track=!n! :sout=#transcode{vcodec=none,acodec=mp3,ab=128,channels=2,samplerate=44100}:std{access="file",mux=raw,dst=!f!} vlc://quit
) ELSE (
CALL vlc -I http cdda:///%s% --cdda-track=!n! :sout=#transcode{vcodec=none,acodec=s16l,ab=224,channels=2,samplerate=48000}:std{access="file",mux=wav,dst=!f!.wav} vlc://quit
)
:eof
Thanks kodela. I've complicated it for convenience of multiple CD ripping. Also some re-factoring and fixes.@philipr: Here is the batch file for ripping an audio CD. I've simplified it a bit:
Code: Select all
@ECHO OFF
REM Ampersand (&) in variables must be escaped (^&).
REM ***** enter metadata *****
SET Artist=Love Song
SET Album=Welcome Back
SET Year=1995
SET Publisher=Word Maranatha
SET Genre=Rock; Pop; Folk; World; Country
REM ***** enter after "SET Track_nn=" the track title. Where nn is within the range of 01 to 99 *****
SET Track_01=A Love Song
SET Track_02=Little Country Church
SET Track_03=Let Us Be One
SET Track_04=Little Pilgrim
SET Track_05=Two Hands
SET Track_06=Freedom
SET Track_07=Take No Chances
SET Track_08=Feel the Love
SET Track_09=Changes
SET Track_10=Front Seat, Back Seat
SET Track_11=The Cossack Song
SET Track_12=And the Wind Was Low
SET Track_13=Welcome Back
SET Track_14=Jesus Puts the Song in Our Hearts
REM ***** enter after "SET d=" the file name elements delimiter character(s) *****
SET d=_
CALL VLC_CD_RIP.bat
Here's the second of the two batch files.The two batch files together are to large for a single post. So I'll post the other one following separately.
Code: Select all
@ECHO OFF
REM This batch file allows you to rip all tracks from an audio CD to MP3 or WAV.
REM However, it must be adapted to the individual circumstances.
REM Typically this batch file is called from a batch file that sets the artist, album, and track song titles.
REM Acquired from Dec 2016 post by kodela at:
REM https://forum.videolan.org/viewtopic.php?t=136816#p451471
REM Changes made Jun 2019 by NOYB:
REM Added vlc --noloop command line option to keep from ending up with zero length files.
REM Parameterized most of the vlc command line options to increase flexibility.
REM Added quotes around the dst value on vlc command line to support folder and file names containing spaces.
REM Added renaming the generic Track_nn file to Artist, Album, Track #, Track Title.
REM Re-factored to eliminate the with_zero and without_zero sub routines.
REM Ampersand (&) in variables must be escaped (^&).
REM Dynamic variables and those that may contain escaped ampersand (^&) need delayed expansion (!var!).
SETLOCAL ENABLEDELAYEDEXPANSION
REM *****
REM *** Begin user defined parameters
REM *****
REM ***** enter after "SET p=" the destination directory for ribbed tracks *****
SET p=C:\Users\%USERNAME%\Desktop\VLC CD RIP\!Artist!\!Album!\
REM ***** enter after "SET m=" for conversion to MP3 > "MP3", to WAV > "WAV" *****
SET m=wav
REM ***** enter after "SET s=" the source directory for the optical drive *****
SET s=D:\
SET samplerate=44100
SET channels=2
REM ***** enter after "CD " the installation directory of vlc.exe *****
SET vlc_cmd=C:\Program Files\VideoLAN\VLC\vlc
REM ***** enter after "SET dry_run=" anything other than "false" (case insensitive) to make a test run without transcoding. *****
SET dry_run=false
REM *****
REM *** End user defined parameters
REM *****
REM *****
REM *** Everything below here is expected to be directed by the above parameters.
REM *****
IF NOT EXIST "!s!" (
ECHO The source location does not exist.
ECHO !s!
ECHO Press any key to abort.
PAUSE >nul
EXIT
)
IF NOT EXIST "!p!" (
MKDIR "!p!"
) ELSE (
ECHO The destination folder already exists.
ECHO Continuing may delete existing content from this folder:
ECHO !p!
CHOICE /C "YN" /M "Do you want to continue anyway?"
IF ERRORLEVEL 2 EXIT
)
CD "!p!"
ECHO Target folder:
ECHO !p!
REM Initialize the track number counter.
SET /a n=0
REM Set the transcoder parameters.
if /i %m%==MP3 (
SET acodec=mp3
SET ab=128
SET mux=raw
) ELSE if /i %m%==WAV (
SET acodec=s16l
SET ab=224
SET mux=wav
) ELSE (
ECHO The specified output type %m% is not valid.
ECHO The output type must be either "MP3" or "WAV".
EXIT
)
REM Loop through the source tracks to transcode them.
FOR /R "%s%" %%L IN (*.cda) DO (CALL :transcode "%%L")
ECHO Finished - Press any key to close.
PAUSE >nul
GOTO :eof
:transcode
Call SET /a n=n+1
IF !n! LEQ 9 (CALL SET nn=0!n!) ELSE (CALL SET nn=!n!)
ECHO Transcoding %1 - !Track_%nn%!
IF /i %dry_run%==false (
CALL "!vlc_cmd!" -I http cdda:///%s% --cdda-track=!n! :sout=#transcode{vcodec=none,acodec=%acodec%,ab=%ab%,channels=%channels%,samplerate=%samplerate%}:std{access="file",mux=%mux%,dst="!p!Track_!nn!.%m%"} --noloop vlc://quit
REN "!p!Track_!nn!.%m%" "!Artist!%d%!Album!%d%!nn!%d%!Track_%nn%!.%m%"
)
:eof
Code: Select all
"!vlc_cmd!" -I http cdda:///%s% --cdda-track=!n! :sout=#transcode{vcodec=none,acodec=%acodec%,ab=%ab%,channels=%channels%,samplerate=%samplerate%}:std{access="file",mux=%mux%,dst="!p!Track_!nn!.%m%"} --noloop vlc://quit
Cannot thank you enough for the transcoding batch file on its own. I just ripped a 40-track CD in seconds thanks to you, leaving me plenty of time to give the tracks their proper file names. As an end-user-focused IT person (i.e., not a code guy), I am so indebted to folks like you who are willing to share their talents with the world. Thanks a ton, and stay well!The two batch files together are to large for a single post. So I'll post the other one following separately.
I know this is ages old, but in case you or someone else still needs this information, here's how to save and run a batch file:Can someone please post directions for these? I don't know what to do with a batch file or how to run it. I am struggling super hard here.
Code: Select all
@ECHO OFF
REM Ampersand (&) in variables must be escaped (^&).
REM Changes made May 2020 by BobR2
REM Introduced a Num_of_Tracks variable and re-factored to manage track titles as an array.
REM ***** enter metadata *****
SET Artist=Love Song
SET Album=Welcome Back
SET Year=1995
SET Publisher=Word Maranatha
SET Genre=Rock; Pop; Folk; World; Country
REM ***** enter after "Num_of_Tracks=" the total number of tracks (Note: must be less than 100) *****
SET Num_of_Tracks=14
REM ***** enter after "SET Track_Title[i]=" the track title. *****
SET Track_Title[1]=A Love Song
SET Track_Title[2]=Little Country Church
SET Track_Title[3]=Let Us Be One
SET Track_Title[4]=Little Pilgrim
SET Track_Title[5]=Two Hands
SET Track_Title[6]=Freedom
SET Track_Title[7]=Take No Chances
SET Track_Title[8]=Feel the Love
SET Track_Title[9]=Changes
SET Track_Title[10]=Front Seat, Back Seat
SET Track_Title[11]=The Cossack Song
SET Track_Title[12]=And the Wind Was Low
SET Track_Title[13]=Welcome Back
SET Track_Title[14]=Jesus Puts the Song in Our Hearts
REM ***** enter after "SET d=" the file name elements delimiter character(s) *****
SET d=_
CALL VLC_CD_RIP_v2_transcoding.bat
Code: Select all
@ECHO OFF
REM This batch file allows you to rip all tracks from an audio CD to MP3 or WAV.
REM However, it must be adapted to the individual circumstances.
REM Typically this batch file is called from a batch file that sets the artist, album, number of tracks, and track song titles.
REM Acquired from Dec 2016 post by kodela at:
REM https://forum.videolan.org/viewtopic.php?t=136816#p451471
REM Changes made Jun 2019 by NOYB:
REM Added vlc --noloop command line option to keep from ending up with zero length files.
REM Parameterized most of the vlc command line options to increase flexibility.
REM Added quotes around the dst value on vlc command line to support folder and file names containing spaces.
REM Added renaming the generic Track_nn file to Artist, Album, Track #, Track Title.
REM Re-factored to eliminate the with_zero and without_zero sub routines.
REM Changes made May 2020 by BobR2
REM Introduced a Num_of_Tracks variable and re-factored to manage track titles as an array.
REM Modified the FOR loop so as to not depend on having the CD be represented as containing a set of "*.cda" files (not all Compact Disk Digital Audio (CD-DA) CDs do)
REM Ampersand (&) in variables must be escaped (^&).
REM Dynamic variables and those that may contain escaped ampersand (^&) need delayed expansion (!var!).
SETLOCAL ENABLEDELAYEDEXPANSION
REM *****
REM *** Begin user defined parameters
REM *****
REM ***** enter after "SET p=" the destination directory for ribbed tracks *****
SET p=C:\Users\%USERNAME%\Desktop\VLC CD RIP\!Artist!\!Album!\
REM ***** enter after "SET m=" for conversion to MP3 > "MP3", to WAV > "WAV" *****
SET m=wav
REM ***** enter after "SET s=" the source directory for the optical drive *****
SET s=D:\
SET samplerate=44100
SET channels=2
REM ***** enter after "CD " the installation directory of vlc.exe *****
SET vlc_cmd=C:\Program Files\VideoLAN\VLC\vlc
REM ***** enter after "SET dry_run=" anything other than "false" (case insensitive) to make a test run without transcoding. *****
SET dry_run=false
REM *****
REM *** End user defined parameters
REM *****
REM *****
REM *** Everything below here is expected to be directed by the above parameters.
REM *****
REM Set the transcoder parameters.
if /i %m%==MP3 (
SET acodec=mp3
SET ab=128
SET mux=raw
) ELSE if /i %m%==WAV (
SET acodec=s16l
SET ab=224
SET mux=wav
) ELSE (
ECHO The specified output type %m% is not valid.
ECHO The output type must be either "MP3" or "WAV".
EXIT
)
IF NOT EXIST "!s!" (
ECHO The source location does not exist.
ECHO !s!
ECHO Press any key to abort.
PAUSE >nul
EXIT
)
IF NOT EXIST "!p!" (
MKDIR "!p!"
) ELSE (
ECHO The destination folder already exists.
ECHO Continuing may delete existing content from this folder:
ECHO !p!
CHOICE /C "YN" /M "Do you want to continue anyway?"
IF ERRORLEVEL 2 EXIT
)
CD "!p!"
ECHO Target folder:
ECHO !p!
REM Loop through the source tracks to transcode them.
FOR /L %%I In (1,1,%Num_of_Tracks%) DO (CALL :transcode %%I)
ECHO Finished - Press any key to close.
PAUSE >nul
GOTO :eof
:transcode
REM Set the two-digit track number with leading zero as needed
IF %1 LEQ 9 (CALL SET ii=0%1) ELSE (CALL SET ii=%1)
ECHO Transcoding Track %1 (!ii!) - !Track_Title[%1]!
IF /i %dry_run%==false (
CALL "!vlc_cmd!" -I http cdda:///%s% --cdda-track=%1 :sout=#transcode{vcodec=none,acodec=%acodec%,ab=%ab%,channels=%channels%,samplerate=%samplerate%}:std{access="file",mux=%mux%,dst="!p!Track_!ii!.%m%"} --noloop vlc://quit
REN "!p!Track_!ii!.%m%" "!Artist!%d%!Album!%d%!ii!%d%!Track_Title[%1]!.%m%"
)
:eof
Could you please post a YouTube video instead? I tried this, and my Windows 10 says it will not open a BAT file.I know this is ages old, but in case you or someone else still needs this information, here's how to save and run a batch file:Can someone please post directions for these? I don't know what to do with a batch file or how to run it. I am struggling super hard here.
1. Select and Copy the text provided by the developer.
2. In a directory of your choice (I use the Desktop for ease of access) right click on an empty area of the screen or in a folder window and choose New-->Text Document
3. Give this new document a descriptive name, AND change the file extension - the part after the dot - from 'txt' to 'bat'. In my case, for instance, I named the file 'VLC_RipCD.bat').
[*]3a. If you can't see the file extension, you'll need to modify the view settings for the containing folder so file extensions are visible.
4. Open this newly created text document, and Paste the copied code from step 1.
[*]4a. In this case, and in many cases of code provided on forums like this, don't forget to change the user-specific details like the directories, transcoding choices, etc.
5. Save and close the batch file (this text document you just created and customized).
6. When you're ready to run the file, right click on it and choose Run as administrator. It's usually fine to just double click the file as if you're opening it, but I prefer to run batch files as admin to bypass potential errors related to user permissions.
Hope this helps.
Could you please post a YouTube video instead? I tried this, and my Windows 10 says it will not open a BAT file.
Why isnt' batch ripping a default option in VLC without a person having to be a computer programmer?
I don't know what a "directory" or "transcoding choice" is, and really I don't much want to. I just wnat to rip some CDs painlessly.
Code: Select all
REM Get the length of the Track_Title array
set Num_of_Tracks=1
:SymLoop
if defined Track_Title[%Num_of_Tracks%] (
set /a Num_of_Tracks+=1
GOTO :SymLoop
)
set /a Num_of_Tracks=%Num_of_Tracks%-1
Return to “VLC media player for Windows Troubleshooting”
Users browsing this forum: No registered users and 43 guests