多年来,我们一直使用以下批处理文件将(合法的)音频 CD 翻录成 MP3,供我们的员工在 iPod 上使用。但自从 Windows 10(Ver 1607 Build 14393.321)以来,它们不再起作用。我认为,问题在于,无论出于什么原因,Windows 不再“看到”光盘驱动器上的 CDA 文件(至少在命令行中)。Windows Media Player 仍可识别驱动器并进行“翻录”,但这非常繁琐。有什么方法可以让这个 BAT 文件再次工作吗?
问题发生在 FOR 循环中...即例程立即退出,因为循环无法“看到”任何 CDA 文件。
FOR /R D:\ %%G IN (D:\*.cda) DO (CALL :TEST_VLC "%%G")
@ECHO OFF
CLS
set OLDDIR=%CD%
SET a=%1
IF %1.==. GOTO :help
SET t=%2
IF %2.==. GOTO :help
SET e=%3
IF %3.==. SET e=mp3
MD %2
CD %2
setlocal ENABLEDELAYEDEXPANSION
@ECHO Ripping %2 from %OLDDIR%
cmd /c wizmo.exe close
GOTO :goforit
:after
endlocal
@ECHO ON
c:\Util\id3\id3.exe -M -t "%a%_%%f" -a %a% -l %t% *.%e%
REM c:\Util\id3\id3 -a "Author_Name" -t "Disc_Title %f" *.mp3
cd /d %OLDDIR%
cmd /c wizmo.exe open
goto :eof
:goforit
ECHO goforit %e% Transcoding %2
SET /a y=0
SET /a PADDED=0%y%
FOR /R D:\ %%G IN (D:\*.cda) DO (CALL :SUB_VLC "%%G")
GOTO :after
:help
@ECHO Syntax: RIP Artist[artist] Subdir[disc1] Format[[mp3]/wav]
GOTO :eof
:TEST_VLC
ECHO After ripping routine
:SUB_VLC
call SET /a y=y+1
echo begin padding
echo pad with your desired width - 1 leading zeroes
call SET PADDED=0%y%
echo slice off any zeroes you don't need -- BEWARE, this can truncate the value
echo the 2 at the end is the number of desired digits
SET PADDED=%PADDED:~-2%
REM end padding
ECHO %e% Transcoding %2 file %PADDED%
REM Here's where the actual transcoding/conversion happens. The next line
REM fires off a command to VLC.exe with the relevant arguments:
ECHO "C:\Program Files (x86)\VideoLAN\VLC\vlc" -I http cdda:///D:/ --cdda-track=!y! :sout=#transcode{vcodec=none,acodec=%e%,ab=320,channels=2,samplerate=44100}:std{access="file",mux=raw,dst="%t%!PADDING!.%e%"} vlc://quit
IF %e%==mp3 CALL "C:\Program Files (x86)\VideoLAN\VLC\vlc" -I http cdda:///D:/ --cdda-track=!y! :sout=#transcode{vcodec=none,acodec=%e%,ab=320,channels=2,samplerate=44100}:std{access="file",mux=raw,dst="%t%!PADDED!.%e%"} vlc://quit
IF %e%==wav CALL "C:\Program Files (x86)\VideoLAN\VLC\vlc" -I http cdda:///D:/ --cdda-track=!y! :sout=#transcode{vcodec=none,acodec=s16l,channels=2}:std{access="file",mux=wav,dst="%t%!PADDED!.%e%"} vlc://quit
:eof
答案1
1)在 中.bat
,在某些情况下,您应该使用%%
而不是一个%
。
2) 我认为问题可能出在不同的地方。您应该调试脚本 - 在底部添加以下行:
ping 127.0.0.1 -n 123 > nul
然后执行该 bat 文件,并查看执行日志,查看哪些操作成功,哪些操作失败。