Batch File - Remove Second File Extension

David Ward picture David Ward · Jun 19, 2011 · Viewed 40.5k times · Source

Using a batch file is there a way that I can strip off the .deploy extension from all files in a directory.

For example

1.txt.deploy => 1.txt
2.txt.deploy => 2.txt 

etc

Answer

Andriy M picture Andriy M · Jun 19, 2011
RENAME *.txt.deploy *.

A more 'fancy' solution:

@ECHO OFF
FOR %%f IN (*.txt.deploy) DO RENAME "%%f" "%%~nf"