中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-09-23 12:56
47,812 topics / 349,917 posts / today 0 new / 48,273 members
DOS批处理 & 脚本技术(批处理室) » [Closed] How to use wildcards with ren to batch rename files
Printable Version  3,602 / 6
Floor1 mf1388 Posted 2008-10-10 20:16
初级用户 Posts 15 Credits 32
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 ]
Floor2 mf1388 Posted 2008-10-10 20:49
初级用户 Posts 15 Credits 32
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 ]
Floor3 buddiyar Posted 2008-10-10 20:57
初级用户 Posts 75 Credits 160
Floor4 mf1388 Posted 2008-10-10 21:06
初级用户 Posts 15 Credits 32
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 ]
Floor5 kissbill Posted 2008-10-11 00:06
初级用户 Posts 35 Credits 61
```
@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
Floor6 everest79 Posted 2008-10-11 05:40
金牌会员 Posts 1,127 Credits 2,564
? represents any single character
* represents any characters
Floor7 zzz19760225 Posted 2017-10-23 14:43
超级版主 Posts 2,020 Credits 3,673
I express that I can't find one point, every time it's two points, I'm so distressed
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023