Reputation: 29
@echo off
echo File Extionsion To Create List?
SET /p Ext=Ext:
echo %Ext%
for /f "tokens=1 delims=." %%g in ('dir /b *.%Ext%') do echo %%g >> Names.txt
How do you remove the last dot and the file extension without accidentally removing other dots. For example 10.01320.pdf will become 10.01320.
Upvotes: 0
Views: 101
Reputation: 1679
Since your goal is to keep all the .
's in the file name just not the extension, you can simply use some Parameter Extensions. In the example of your goal, %%~ng
will Expand %%g
to a file Name without file extension or path.
@echo off
echo File Extionsion To Create List?
SET /p Ext=Ext:
echo %Ext%
for /f "tokens=1 delims=*" %%g in ('dir /b *.%Ext%') do echo %%~ng >> Names.txt
Upvotes: 3