次のバッチは、wmicを
- ロケール/ユーザー設定に依存しない日付を取得する
- 利用可能なドライブ文字のリストを取得する
- と文字を選択するための選択
:: 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
サンプルダイアログ:
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...