@echo off setlocal ENABLEDELAYEDEXPANSION type nul>ext type nul>ext.txt FOR /r D:\Desktop\xlslib %%i in (*) do @echo %%~xi >> ext for /f "delims=" %%e in ('sort ext') do ( if not defined %%e set %%e=Def & >>ext.txt echo %%e ) notepad ext.txt