Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch File - Remove Second File Extension

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

like image 811
David Ward Avatar asked Jun 19 '11 10:06

David Ward


People also ask

How do I remove a double filename extension?

Open File Explorer and click View tab, Options. In Folder Options dialog, move to View tab, untick Hide extensions for known file types option, OK. Then you will se file's extension after its name, remove it.

How do I delete multiple file extensions in CMD?

You can do this using the Windows GUI. Enter "*. wlx" in the search box in explorer. Then after the files have been found, select them all (CTRL-A) and then delete using the delete key or context menu.


1 Answers

RENAME *.txt.deploy *.

A more 'fancy' solution:

@ECHO OFF
FOR %%f IN (*.txt.deploy) DO RENAME "%%f" "%%~nf"
like image 194
Andriy M Avatar answered Oct 16 '22 06:10

Andriy M