How to Re-Number the Files Sequentially on Windows using Batch P

  • 时间:2020-09-18 17:26:09
  • 分类:网络文摘
  • 阅读:145 次

You probably have a list of files e.g. camera pictures that you want to re-number sequentially. For example, the photos are named using dates-and-time string.

image-list-with-dates How to Re-Number the Files Sequentially on Windows using Batch Programming/Script? batch script tools / utilities windows windows batch

image-list-with-dates

However, this is not idea, as many of us want to re-name the files sequentially and possibly with a prefix.

images-re-numbered How to Re-Number the Files Sequentially on Windows using Batch Programming/Script? batch script tools / utilities windows windows batch

images-re-numbered

Using the batch script below, we can easily rename all files in the same folder sequentially.

1
2
3
4
5
6
7
8
9
10
11
@echo off
REM rename-tool.cmd
setlocal enabledelayedexpansion
 
set num=1
for %%f in (*.%2) do (
    ren "%%f" "%1!num!.%2"
    rem increment the numbering
    set /a num=!num!+1
)
endlocal
@echo off
REM rename-tool.cmd
setlocal enabledelayedexpansion

set num=1
for %%f in (*.%2) do (
	ren "%%f" "%1!num!.%2"
	rem increment the numbering
	set /a num=!num!+1
)
endlocal

Example usage:

1
rename-tool myfiles- jpg
rename-tool myfiles- jpg

The first parameter is the prefix, and the second parameter the file suffix (extension). The above batch script may fail to rename some files if the target file exists, thus it is better to choose a different prefix when first time renaming all the files in the folder.

–EOF (The Ultimate Computing & Technology Blog) —

推荐阅读:
常吃辛辣烫的食物易患消化道肿瘤  老年人可适当吃些零食保证营养需求  盘点网上那些错误的营养禁忌“神话”  食品科学博客解读网络盛传营养误区  中国运动营养食品标准 有规矩才成方圆  健康瘦身:食物搭配让减肥与营养兼顾  保健养生:秋季的健康饮食的营养原则  进口食品营养标签必须符合国家规定  如何读懂包装食品营养标签核心信息  食用油的选择:解密食用油养生之道 
评论列表
添加评论