Reputation: 464
I have a lot of *.lub.lua files, and I want them to have only the .lua extension. I've used the for /r %%x in (*.lub.lua) do if exist "%%x" ren "%%x" *.lua
but it doesn't take the .lub part away. What should I do?
Upvotes: 0
Views: 100
Reputation: 79982
@echo off
for /r %%a in (*.lub.lua) do for %%b in ("%%~na") do echo(ren "%%a" "%%~nb.lua"
The required REN commands are merely ECHO
ed for testing purposes. After you've verified that the commands are correct, change ECHO(REN
to REN
to actually rename the files.
Upvotes: 1
Reputation: 67206
@echo off
setlocal EnableDelayedExpansion
for /R %%x in (*.lub.lua) do (
set name=%%~Nx
ECHO ren "%%x" "!name:.lub=.lua!"
)
This program just display the ren
commands; if they are correct, remove the ECHO
part in order to execute they.
Upvotes: 1