Rps
Rps

Reputation: 277

batch script: recursivle renaming files with multiple extensions

so to make myself a little more clear

file1.ext1.ext2 >>  file1.ext2
file2.ext3.ext4 >>  file2.ext4
...
           ->rename to->

I'm trying to achieve this with a for loop but I am stuck

for %%i in (c:/) do ren %%i.??? to %%~ni.???

any could give me a hint

Upvotes: 2

Views: 1031

Answers (1)

jeb
jeb

Reputation: 82410

This should work

@echo off
for %%a in (file*) do (
    for %%f in ("%%~na") do (
        ECHO ren %%~a %%~nf%%~xa
    )
)

Upvotes: 1

Related Questions