Home » Kho Tri Thức
How to extract a complete list of extension types within a directory?
Thứ Hai, 19 tháng 4, 2021
Bởi: Đoàn Thành Trung
List file type trong một thư mục bao gồm cả các thư mục con.
save nội dung đoạn lệnh bên dưới vào file .bat và chạy lệnh : batchfile >filename.txt
@echo off
set target=%~1
if "%target%"=="" set target=%cd%
setlocal EnableDelayedExpansion
set LF=^
rem Previous two lines deliberately left blank for LF to work.
for /f "tokens=*" %%i in ('dir /b /s /a:-d "%target%"') do (
set ext=%%~xi
if "!ext!"=="" set ext=FileWithNoExtension
echo !extlist! | find "!ext!:" > nul
if not !ERRORLEVEL! == 0 set extlist=!extlist!!ext!:
)
echo %extlist::=!LF!%
endlocal

Comments[ 0 ]
Đăng nhận xét