Extract a list of files names from a folder using CMD
Discussion
I want to extract a list of filename with the path using the DIR function under CMD but I only want to return the records with a file, I don't want to include all the folders i.e
If I had
c:\Temp\1.txt
c:\Temp\2.txt
c:\temp\test\5.txt
I would only want
c:\temp\1.txt
c:\temp\2.txt
c:\temp\test\5.txt
Not to include
c:\Temp
c:\temp\test
Is this possible to exclude the folders and just return the files?
If I had
c:\Temp\1.txt
c:\Temp\2.txt
c:\temp\test\5.txt
I would only want
c:\temp\1.txt
c:\temp\2.txt
c:\temp\test\5.txt
Not to include
c:\Temp
c:\temp\test
Is this possible to exclude the folders and just return the files?
I find the OPs request a bit confusing?
c:\temp\1.txt
c:\temp\2.txt
c:\temp\test\5.txt
The impression I get is that they only want to return:
1.txt
2.txt
5.txt
Without the directory / folder names?
c:\temp\1.txt
c:\temp\2.txt
c:\temp\test\5.txt
The impression I get is that they only want to return:
1.txt
2.txt
5.txt
Without the directory / folder names?
ThingsBehindTheSun said:
<snip>
Is this possible to exclude the folders and just return the files?
If so then:Is this possible to exclude the folders and just return the files?
FOR /R %F IN (*) DO @IF NOT EXIST "%F\" ECHO %~nxF
** Or in a batch file:
FOR /R %%F IN (*) DO (
IF NOT EXIST "%%F\" ECHO %%~nxF
)
Edited by TonyRPH on Thursday 3rd July 09:56
Gassing Station | Computers, Gadgets & Stuff | Top of Page | What's New | My Stuff