show files without extension

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
dukdpk
Posts: 13
Joined: 10 Mar 2011 03:27

show files without extension

#1 Post by dukdpk » 25 Mar 2011 01:00

Hi All

E:\MyProgramme contains number of files with different extensions. I want to show only all files with .exe , Please note that display file name only. Not display extension(i.e. .exe ). Please advice me how to write bat file for above requirement. I tried following one but display files with file extension.

DIR /B "E:\MyProgramme\*.exe" /O:d

Thank you

scienceguru1.bat
Posts: 44
Joined: 01 Jan 2011 20:54

Re: show files without extension

#2 Post by scienceguru1.bat » 25 Mar 2011 06:32

1)open the command prompt
2)type "H:" then hit enter
3)type "cd (folder name)" then hit enter
4)type "dir /b "*.exe""

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: show files without extension

#3 Post by aGerman » 25 Mar 2011 15:19

Process the DIR command in a FOR loop and use the ~n option to display only the file name.

Code: Select all

for /f "delims=" %%a in ('dir /a-d /b ""E:\MyProgramme\*.exe"') do echo %%~na

Regards
aGerman

dukdpk
Posts: 13
Joined: 10 Mar 2011 03:27

Re: show files without extension

#4 Post by dukdpk » 28 Mar 2011 01:28

hi aGerman

It works. thank you.

for /f "delims=" %%a in ('dir /a-d /b "E:\MyProgramme\*.exe"') do echo %%~na

Post Reply