Skip to content

Instantly share code, notes, and snippets.

@Vuzereus
Created September 24, 2025 05:57
Show Gist options
  • Save Vuzereus/0d9bee9cbbc4ba6d1755618f3d534ebb to your computer and use it in GitHub Desktop.
Save Vuzereus/0d9bee9cbbc4ba6d1755618f3d534ebb to your computer and use it in GitHub Desktop.
A batch file to create filelist in a Windows drive.
@echo off & setlocal enableextensions
set target_=%1%:
::
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_%
echo Update %target_% to D:\Filelist\Disk_%label_%.txt
dir %target_%\ /s /b > D:\Filelist\Disk_%label_%.txt
echo Done
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment