Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a folder that has a bunch of files such image_hello.png, helloworld.png, wired.png. I would like to copy these files and then rename them as 1.png, 2.png, 3.png via script or batch file

I am not sure what the best way to start this is, i can copy over the files easily, but after that, i am not sure how to rename them based on the extension.

Any ideas?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
213 views
Welcome To Ask or Share your Answers For Others

1 Answer

Something like this:

@echo off
SET count=1
FOR /f "tokens=*" %%G IN ('dir /b *.png') DO (call :rename_next "%%G")
GOTO :eof

:rename_next
ren "%1" %count%.png
set /a count+=1
GOTO :eof

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...