China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-01 20:07
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Renaming files View 898 Replies 5
Original Poster Posted 2006-06-13 11:00 ·  中国 上海 联通
新手上路
Credits 8
Posts 2
Joined 2006-06-02 15:03
20-year member
UID 56430
Gender Male
Status Offline
Experts, I want to use a batch script to rename files in a certain folder. The renaming rule is as follows:
Take part of the original filename, then add a new suffix after it, for example
AVCQ01DY.ZIP.2006050202.ar
AVCQ01DY.ZIP.2006050302.ar
change to
AVCQ01DY.ZIP.2006050202.zip
AVCQ01DY.ZIP.2006050302.zip
How should this script be written?
Thanks!
Floor 2 Posted 2006-06-13 11:51 ·  中国 湖北 荆门 电信
荣誉版主
★★★
Credits 2,013
Posts 718
Joined 2006-02-18 07:07
20-year member
UID 50550
Status Offline

@echo off
for %%i in (%*) do ren "%%~dpnxi" "%%~ni.zip"

This should roughly meet your requirements. Of course, you can also modify it yourself according to the situation.
Floor 3 Posted 2006-06-13 13:04 ·  中国 上海 联通
新手上路
Credits 8
Posts 2
Joined 2006-06-02 15:03
20-year member
UID 56430
Gender Male
Status Offline
Thanks, boss, this command does run correctly.
But I'm just a beginner with batch, could you explain what the two parameters "%%~dpnxi" and "%%~ni.zip" mean?
Thanks!
Floor 4 Posted 2006-06-13 15:11 ·  IANA 局域网IP(Private-Use)
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
My answer is very simple:
ren *.ar *.zip

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 5 Posted 2006-06-14 08:06 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
Floor 6 Posted 2006-06-14 16:38 ·  中国 贵州 贵阳 电信
中级用户
★★
Credits 304
Posts 117
Joined 2006-04-04 18:43
20-year member
UID 53325
Gender Male
Status Offline
It really was made too complicated!!!
Forum Jump: