使用批处理文件解析文件名,自动化有声书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:\VRDTBdirectory exists. If your card uses a different drive letter, just update thetargetRootvariable. - Duplicate Protection: It warns you if the book folder already exists and asks before overwriting— no accidental data loss!
- Robust Copy: Uses
xcopywith 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
- Open Notepad, paste the script (pick either manual title input or auto-detect).
- Save it with a
.batextension (likeAudiobookTransfer.bat). - 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
相关产品推荐
相关产品推荐

