O lote a seguir usa o wmic para
- obtenha uma data independente de localidade / configurações de usuário
- obtenha uma lista de letras de unidades disponíveis
- e escolha para selecionar uma letra
:: makelist.bat
@Echo off&SetLocal EnableExtensions EnableDelayedExpansion
set Started=%date% %time%
:: get locale/user-settings independent date
for /f "delims=." %%A in (
'wmic os get LocalDateTime^|findstr ^^[0-9]'
) do Set "DT=%%A"
Set MyDate=%DT:~0,4%-%DT:~4,2%-%DT:~6,2%
:: gather available drives
Set "Drives="
FOr /f "delims=:" %%A in (
'Wmic logicaldisk get name^|findstr "^[A-Z]:"'
) DO Set "Drives=!Drives!%%A"
:: choose drive letter
Choice /C %Drives% /M "Select drive letter for tree"
Set /A "Inp=%Errorlevel%,Pnt=Inp-1"
IF %Inp% equ 0 Echo aborted & pause & exit /B 1
If %Inp% equ 255 Echo aborted & pause & exit /B 1
Set "Drive=!Drives:~%Pnt%,1!"
:: do the tree
Echo %Started% Tree started
Echo Tree %Drive%:\ /F /A "%UserProfile%\Desktop\Tree_%Drive%_%MyDate%.txt"
Tree %Drive%:\ /F /A >"%UserProfile%\Desktop\Tree_%Drive%_%MyDate%.txt"
Echo %date% %time% done
timeout -1
Diálogo de exemplo:
Select drive letter for tree [C,D,E,G,H,K,M,N,P,Q,R,T,U,V,W,X,Z]?H
2017-03-13 14:17:05,45 Tree started
Tree H:\ /F /A "C:\Users\UserName\Desktop\Tree_H_2017-03-13.txt"
2017-03-13 14:17:13,70 done
Drücken Sie eine beliebige Taste, um den Vorgang fortzusetzen...