hi dostips batch scripters,
is it possible to remove unwanted file extension in a text document?
for example,
ref.txt
---------------content-----------------
123.jpg
456.jpg
789.jpeg
def.bmp
ghi.bmp
jkl.pdf
abc.pdf
*.*etc
--------------content end--------------
i use the notepad replace feature & it works but for large number of
different file extensions, it is quite time consuming!!
can bat remove those file extension with ease???
so that the result will be as below,
ref.txt <- filter out
---------------content-----------------
123
456
789
def
ghi
jkl
abc
--------------content end--------------
thanks in advance!!
remove unwanted file extension!!! help!
Moderator: DosItHelp
Re: remove unwanted file extension!!! help!
Code: Select all
@echo off
move ref.txt ref.bak
for /f "delims=" %%a in (ref.bak) do echo %%~na>> ref.txt
-
- Posts: 319
- Joined: 12 May 2006 01:13
Re: remove unwanted file extension!!! help!
download sed for windows at gnuwin32.sourceforge.net/packages/sed.htm
Code: Select all
sed -i.bak "s/\..*$//" file