复制并通过批处理文件重新命名了一定的扩展的文件 [英] copy and rename files of a certain extension via batch file

查看:371
本文介绍了复制并通过批处理文件重新命名了一定的扩展的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有了一堆文件,例如image_hello.png,helloworld.png,wired.png一个文件夹。我想通过脚本或批处理文件将它们复制这些文件,然后重命名为1.png,2.png,3.png

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.

任何想法?

推荐答案

事情是这样的:

@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

这篇关于复制并通过批处理文件重新命名了一定的扩展的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆