You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用批处理文件解析文件名,自动化有声书SD卡整理流程

Automating Audiobook CD Transfer for Daisy Streamer (Batch Script)

Hey there! First off, huge props for putting in 9 years of volunteer work to help your visually impaired friend access their audiobooks— that’s such meaningful work. I know how tedious those repetitive steps can get, so here’s a batch script tailored exactly to your workflow to automate the process:

The Batch Script

@echo off
setlocal enabledelayedexpansion

:: Set your SD card's target root directory (adjust drive letter if needed)
set "targetRoot=F:\VRDTB"

:: Check if the SD card is connected and the directory exists
if not exist "%targetRoot%" (
    echo Oops! Can't find the SD card directory %targetRoot%. Make sure the card is inserted properly.
    pause
    exit /b 1
)

:: Prompt for the book title (matches what you'd use to name the folder)
set /p "bookTitle=Enter the book title (double-check it matches the CD label): "

:: Clean up any accidental extra spaces in the title
set "bookTitle=!bookTitle: =!"
if "!bookTitle!"=="" (
    echo Error: Book title can't be empty!
    pause
    exit /b 1
)

:: Handle duplicate folders to avoid overwriting by mistake
set "targetFolder=%targetRoot%\!bookTitle!"
if exist "!targetFolder!" (
    echo Heads up: A folder named "!bookTitle!" already exists on the SD card.
    set /p "overwrite=Do you want to replace its content? (Y/N): "
    if /i not "!overwrite!"=="Y" (
        echo Operation cancelled— no changes made.
        pause
        exit /b 0
    )
    :: Delete existing folder to make way for fresh content
    rmdir /s /q "!targetFolder!"
)
mkdir "!targetFolder!"

:: Get the CD drive letter (since CD drives don't always use the same letter)
set /p "cdDrive=Enter the CD drive letter (e.g., D:): "
if not exist "%cdDrive%\" (
    echo Error: Can't find the CD drive %cdDrive%. Make sure the CD is inserted.
    pause
    exit /b 1
)

:: Copy all content from the CD to the target folder
echo Copying CD content to "!bookTitle!" folder...
xcopy "%cdDrive%\*" "!targetFolder!\" /E /H /C /I /Y

:: Let you know if the copy succeeded or failed
if %errorlevel% equ 0 (
    echo Done! The book "!bookTitle!" is ready for the Daisy Streamer.
) else (
    echo Uh-oh! The copy failed with error code %errorlevel%. Double-check the CD and try again.
)

pause
endlocal

Key Details & Customization Tips

  • SD Card Check: The script first verifies your SD card’s F:\VRDTB directory exists. If your card uses a different drive letter, just update the targetRoot variable.
  • Duplicate Protection: It warns you if the book folder already exists and asks before overwriting— no accidental data loss!
  • Robust Copy: Uses xcopy with flags to grab every file (including hidden/system files), copy subfolders, and keep going even if minor errors pop up.
  • Auto-Detect CD Title (Optional): If your CDs have volume labels that match the book title, you can replace the manual title prompt with this code to auto-grab the label:
    :: Auto-detect CD volume label instead of typing it
    for /f "tokens=2 delims=:" %%d in ('wmic logicaldisk where "drivetype=5" get volumename /value') do (
        set "bookTitle=%%d"
    )
    :: Clean up extra spaces from the detected label
    set "bookTitle=!bookTitle: =!"
    if "!bookTitle!"=="" (
        echo Couldn't detect the CD label— please enter it manually.
        set /p "bookTitle=Enter the book title: "
    )
    

How to Use

  1. Open Notepad, paste the script (pick either manual title input or auto-detect).
  2. Save it with a .bat extension (like AudiobookTransfer.bat).
  3. Double-click the file when you’re ready to transfer a CD, then follow the prompts.

This should cut down all the repetitive clicking and typing so you can spend less time on logistics and more time supporting your friend.

内容的提问来源于stack exchange,提问作者PeeDeeVee

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 10:25:24