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?
@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.
@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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.