|
coolstar14
初级用户
 
积分 111
发帖 4
注册 2005-2-20
状态 离线
|
『楼 主』:
[求助]如何实现文件批量重命名(1.rm --> 001.rm 这样的)
使用 LLM 解释/回答一下
从网上下载过一些文件, 命令规则为 1.rm 2.rm ... 11.rm 12.rm ... 100.rm 这样的.
在资源管理器里按文件名排序就不太爽了, dos下有没有方便的方法可以统一的补全三(或指定位数), 即 1.rm --> 001.rm 11.rm --> 011.rm 这样的.
另, 有的情况下, 数字前面还带些前缀, 如 sanguo1.rm 这样的, 应该改成 sanguo001.rm这样.
试了半天的for 一直不行, 求助各位大侠, 请多多指教.
I have downloaded some files from the internet, and the command rules are like 1.rm, 2.rm... 11.rm, 12.rm... 100.rm, etc.
It's not very pleasant to sort by file name in Windows Explorer. Is there a convenient way under DOS to uniformly complete to three (or a specified number of) digits, that is, 1.rm --> 001.rm, 11.rm --> 011.rm, etc.
Also, in some cases, there are some prefixes in front of the number, such as sanguo1.rm, which should be changed to sanguo001.rm, etc.
I've been trying the for command for a long time and it doesn't work. I'm asking for help from all the experts, please give more advice.
|
|
2005-2-20 00:00 |
|
|
chenhui530
高级用户
   
积分 772
发帖 273
注册 2004-10-23
状态 离线
|
|
2005-2-20 00:00 |
|
|
chenhui530
高级用户
   
积分 772
发帖 273
注册 2004-10-23
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
如果你的系统是nt构架的话可以使用FOR语句for /l %%a in (1,1,99) do ren sanguo%%a.txt 0%%a.txt
If your system is of the NT architecture, you can use the FOR statement for /l %%a in (1,1,99) do ren sanguo%%a.txt 0%%a.txt
|

http://www.msfans.net/bbs/ |
|
2005-2-20 00:00 |
|
|
chenhui530
高级用户
   
积分 772
发帖 273
注册 2004-10-23
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
for /l %%a in (1,1,99) do ren sanguo%%a.rm 0%%a.rm
for /l %%a in (1,1,99) do ren sanguo%%a.rm 0%%a.rm
|

http://www.msfans.net/bbs/ |
|
2005-2-20 00:00 |
|
|
coolstar14
初级用户
 
积分 111
发帖 4
注册 2005-2-20
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
谢谢楼上.
我是2000系统, 所有你给的答案应该是正解了.
我刚试了一把, 基本应该算成功的. 它确实在每个文件前面都加了个0, 虽然不像我希望的那样( 可以区分出位数, 统一补全对应的位数,像sg1.rm 补为 sg001.rm sg10.rm 则只补1个0为sg010.rm), 但稍麻烦一点把这个命令使用两遍也就是了.
另: 对于其中的语法解释我还不是太明白, 正在找Window的帮助, 如果大侠方便, 能不能稍微解释一下.
Thanks to the person above.
I'm using Windows 2000, and all the answers you provided should be correct.
I just tried it and it basically worked. It did add a 0 in front of each file. Although it's not exactly what I wanted (where I could distinguish the number of digits and pad them to the corresponding number of digits, like sg1.rm to sg001.rm and sg10.rm to sg010.rm by adding only one 0), it's a bit cumbersome, but I can just use the command twice.
Also: I don't quite understand the grammar explanation yet. I'm looking for Windows help. If it's convenient for you, can you explain it a little?
|
|
2005-2-20 00:00 |
|
|
coolstar14
初级用户
 
积分 111
发帖 4
注册 2005-2-20
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
受教了.
我知道之前我弄了半天For 为什么不行了, 思路不对的啦.
之前我的思路是局限在从文件名上取变量, 根本没想到可以直接用 1 -99 当变量的说.
我原来 是这样用的 for %a in (sg?.rm) do echo ren %a ...
很明显上面那句是可以列出所有符合要求的文件, 但实际命令中因为无法取到数字部分, 所以只能是失败了.
OK, 再次感谢楼上, 不仅是解决问题, 而且教会我一种新的思路.
Got it.
I know why it didn't work for a long time before. The thinking was wrong.
Before, my thinking was limited to getting variables from the file name. I never thought that I could directly use 1 - 99 as variables.
I originally used it like this: for %a in (sg?.rm) do echo ren %a...
It's obvious that the above sentence can list all the files that meet the requirements, but in the actual command, because the digital part cannot be obtained, it can only fail.
OK, thank you again to the upstairs. Not only did it solve the problem, but it also taught me a new way of thinking.
|
|
2005-2-20 00:00 |
|
|
chenhui530
高级用户
   
积分 772
发帖 273
注册 2004-10-23
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
没有大家互相学习多实践就能找出答案
Without everyone learning from each other and practicing more, we can't find the answer
|

http://www.msfans.net/bbs/ |
|
2005-2-20 00:00 |
|
|
Climbing
铂金会员
       网络独行侠
积分 6962
发帖 2753
注册 2003-4-16 来自 河北保定
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
用命令怪麻烦的,安装一个拖把更名器,想怎么改就怎么改。
It's a bit troublesome with commands. Install a Mop Rename Utility, and you can change it however you want.
|

偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
|
|
2005-2-20 00:00 |
|
|
bush
银牌会员
    
积分 2165
发帖 730
注册 2004-4-21
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
的確受教!nt命令行較之dos真是改變很大呀!
Indeed, I've learned a lot! The nt command line is really quite different from DOS!
|
|
2005-2-21 00:00 |
|