How to work without showing an extension (batch)

For example, I have a folder d: \ temp \ and four document document files in it (.doc)

I know that

dir /b "d:\temp"

will give to me

File1.doc
File2.doc
File3.doc
File4.doc

But how can I make it so that there are only file names without extensions?

as

File1
File2
File3
File4
+4
source share
3 answers
for %a in ("d:\temp\*") do @echo %~na

or for a batch file:

for %%a in ("d:\temp\*") do @echo %%~na

to display also directories that you can use:

for /f "delims=" %%a in (' dir /f "d:\temp\*"') do @echo %%~na
+7
source

Another version with slight differences from the above:

for /f %x in ('dir /b /on *.doc') do @echo %~nx
+1
source

, @echo off, :

for /f "skip=7 tokens=5 delims=. " %%g in ('dir d:\temp') do echo %%g

. F:\thumb.

: for /f "tokens=1 delims=." %%g in ('dir /b d:\temp') do echo %%g

.

0

All Articles