@echo off setlocal EnableDelayedExpansion for /f %%a in ('"wmic logicaldisk where DriveType="3" get DeviceID |find ":""') do ( SET N=%%a DIR !N! >LIST.TXT ) pause