user1084113
user1084113

Reputation: 962

DOS renaming files troubleshooting

I am trying to batch rename several files that are named using the following scheme: picture.scn_xxx.png.

I've tried the following in command:

ren picture.scn_*.png image*.png

However, this does not give me the desired result, I get image.scn_xxx.png instead. The .scn isn't removed( I was hoping to get imagexxx.png)

Upvotes: 0

Views: 117

Answers (1)

dbenham
dbenham

Reputation: 130839

for /f "tokens=1* delims=_" %A in ('dir /b /a-d "picture.scn_*.png"') do ren "picture.scn_%B" "picture%B"

If used in a batch file then %A and %B must change to %%A and %%B

Upvotes: 1

Related Questions