gpt4 book ai didi

windows - 如何读取批处理文件中驱动器或卷的标签?

转载 作者:可可西里 更新时间:2023-11-01 09:48:52 25 4
gpt4 key购买 nike

我正在尝试编写一个批处理文件来将我的 dvd 翻录到硬盘上。我希望文件名成为 DVD 的卷标,但我无法确定在批处理文件中读取磁盘标签的方法。

有没有办法在批处理文件中检索驱动器的卷标,以便我可以将其用作文件名?

最佳答案

更全面。编程为我们有的子程序

@echo off & setlocal enableextensions
set target_=D:
::
call :IsDeviceReady %target_% isready_
echo Device %target_% ready: %isready_%
if /i "%isready_%"=="false" (endlocal & goto :EOF)
::
call :GetLabel %target_% label_
echo The label of Volume %target_% is %label_%
endlocal & goto :EOF
::
:IsDeviceReady
setlocal
set ready_=true
dir "%~1" > nul 2>&1
if %errorlevel% NEQ 0 set ready_=false
endlocal & set "%2=%ready_%" & goto :EOF
::
:GetLabel
setlocal
for /f "tokens=5*" %%a in (
'vol "%~1"^|find "Volume in drive "') do (
set label_=%%b)
endlocal & set "%2=%label_%" & goto :EOF

最初来自http://www.netikka.net/tsneti/info/tscmd101.htm#label

关于windows - 如何读取批处理文件中驱动器或卷的标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8649934/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com