finding file names?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

how can i get just the file name and extensions of all the files in the temp
directory and sub directories then append it to a file?
 
Royce said:
how can i get just the file name and extensions of all the files in the temp
directory and sub directories then append it to a file?
Hi,

This will just list the file names (directories are excluded):

dir %temp% /b /s /a-d


To redirect the output to the file c:\dir.txt:

dir %temp% /b /s /a-d >c:\dir.txt
 
thats what im looking for, but without the path. i just want all the file
names and extensions to be appened to a file
 
Royce said:
thats what im looking for, but without the path. i just want all the file
names and extensions to be appened to a file
Hi,

This should do it:

--------------------8<----------------------
@echo off
setlocal
set outfile="c:\dir.txt"
del %outfile%
for /f "tokens=*" %%i in ('dir "%temp%" /b /s /a-d') do (
echo %%~nxi >>%outfile%
)
endlocal
--------------------8<----------------------
 
Back
Top