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 12:15
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Closed] How to use wildcards with ren to batch rename files View 3,484 Replies 6
Original Poster Posted 2008-10-10 20:16 ·  中国 四川 成都 联通
初级用户
Credits 32
Posts 15
Joined 2008-02-29 21:26
18-year member
UID 111747
Gender Male
Status Offline
I want to create a DOS batch to change file names. There are multiple files, and I want to change them to a unified name. For example, mmm1.txt, mmm2.txt, mmm*.txt...n are changed to bbb1.txt, bbb2.txt, bbb*.txt. I wrote ren mmm*.txt bbb*.txt, but it became bbbmmm1.txt. How to write it to become bbb1.txt?

───────────────── Moderation Record ─────────────────
Performed by: HAT
Operation: Added search keywords to the post title on 2008-10-10
Description: The original title " How to use ren" is not conducive to forum search
Punishment: Deducted 2 points of points
Tip: It is suggested to read the following posts
{1415}The Wisdom of Asking Questions
{7326}Must-read for Forum Newcomers, Basic Code of Conduct for Everyone
{22703}Please Don't Be an Impatient Person
{32667}Those Who Can't Even Write a Clear Title, Wake Up
{32825}This Board Severely Rectifies Poor Posts
───────────────── Moderation Record ─────────────────


[ Last edited by HAT on 2008-10-13 at 14:00 ]
Recent Ratings for This Post ( 3 in total) Click for details
RaterScoreTime
HAT -2 2008-10-10 20:35
DOSforever +2 2008-10-11 02:14
zzz19760225 +2 2017-10-23 14:41
Floor 2 Posted 2008-10-10 20:49 ·  中国 四川 成都 联通
初级用户
Credits 32
Posts 15
Joined 2008-02-29 21:26
18-year member
UID 111747
Gender Male
Status Offline
What are wildcards? I don't even know, I haven't learned yet!!!!!

Gotta go see about wildcards, right?

[ Last edited by mf1388 on 2008-10-10 at 20:53 ]
Floor 3 Posted 2008-10-10 20:57 ·  中国 江苏 苏州 电信
初级用户
★★
Credits 160
Posts 75
Joined 2006-06-28 01:07
20-year member
UID 57661
Gender Male
Status Offline
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
zzz19760225 +2 2017-10-23 14:42
Floor 4 Posted 2008-10-10 21:06 ·  中国 四川 成都 联通
初级用户
Credits 32
Posts 15
Joined 2008-02-29 21:26
18-year member
UID 111747
Gender Male
Status Offline
Originally posted by buddiyar at 2008-10-10 08:57 PM:
Use ?, not *.



Thanks. 3rd floor

Change to ren mmm?.txt ddd?.txt

ddd?.txt Chinese ?.txt Renamed with Chinese

[ Last edited by mf1388 on 2008-10-10 at 21:48 ]
Floor 5 Posted 2008-10-11 00:06 ·  中国 天津 电信
初级用户
Credits 61
Posts 35
Joined 2008-10-04 13:00
17-year member
UID 127389
Gender Male
Status Offline
```
@echo off&setlocal EnableDelayedExpansion
for /f %%i in ('dir /a-d /b *.txt') do (set name=%%i
ren %%~ni.txt bbb!name:~4,1!.txt
)
pause
```
Only like this
Floor 6 Posted 2008-10-11 05:40 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
? represents any single character
* represents any characters
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
zzz19760225 +2 2017-10-23 14:41
49206C6F766520796F752067757973 54656C3A3133383238343036373837
Floor 7 Posted 2017-10-23 14:43 ·  中国 海南 海口 电信
超级版主
★★★★
Credits 3,673
Posts 2,020
Joined 2016-02-01 00:00
10-year member
UID 181465
Gender Male
Status Offline
I express that I can't find one point, every time it's two points, I'm so distressed
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
523066680 +3 2017-11-21 14:42
1<词>,2,3/段\,4{节},5(章)。
Forum Jump: