Using rename command in a batch file in Windows is there a clear way for remove the First File Extension from all files in a directory. For example
1.txt.png => 1.png
2.txt.png => 2.png
Now I use two renaming methods that work. But in my opinion, these methods look "dirty".
1 method. I don't like the 1st method because I exec rename twice.
rename *.txt.png *.
rename *.txt *.png
2 method. I don't like the 2nd method because the number of characters "?" can theoretically be smaller than the basic name (without extension) of the file.
rename *.txt.png ??????????????????????????????.png
? Clear method
I would like to run a command like rename *.txt.png *.png but it doesn't work.
Here is a
cmdcommand that will rename the file as described. When you are confident that the file(s) will be renamed correctly, remove-WhatIffrom theRename-Itemcommand.If you are using the older Windows PowerShell instead of PowerShell Core, change
pwshtopowershell.