|
23112656
中级用户
  
积分 220
发帖 99
注册 2008-6-26
状态 离线
|
『楼 主』:
[已结]如何批量修改文件名?
使用 LLM 解释/回答一下
我先说一下情况`我电脑里有N张JPG格式的图片,而图片的名字又乱七八糟,有没有办法把这些图片的名字从1开始,然后顺序的改名下去?比如:1.jpg 2.jpg 3.jpg
我试了很多办法还是不行啊.我想应该要用到FOR /L 命令吧?但改来改去只能在一个文件上改名`我郁闷啊```求各位高手支招```
最后麻烦各位高手能把详细的代码说明一下`再次感谢```
Last edited by HAT on 2008-11-19 at 17:08 ]
I'll first state the situation. There are N JPG - format pictures in my computer, and the names of the pictures are all jumbled. Is there a way to rename these pictures starting from 1 and renaming them in sequence? For example: 1.jpg, 2.jpg, 3.jpg. I've tried many methods but still can't make it work. I think I should use the FOR /L command, but no matter how I change it, I can only rename one file. I'm really depressed. Please, all you experts, give me some advice.
Finally, please trouble all the experts to explain the detailed code. Thanks again.
Last edited by HAT on 2008 - 11 - 19 at 17:08 ]
|
|
2008-7-28 02:26 |
|
|
pusofalse
银牌会员
    
积分 1604
发帖 646
注册 2008-4-13
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
|

心绪平和,眼藏静谧,无比安稳的火... Purification of soul...Just a false...^_^ |
|
2008-7-28 05:20 |
|
|
523066680
银牌会员
     SuperCleaner
积分 2362
发帖 1133
注册 2008-2-2
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
短 超短……无语……无奈……羡慕……
楼上的代码已经简洁到没什么可以解释的了,有的话就是call部分……这是一个很好的
例子,楼主要掌握技巧哦!(郁闷……我不会这个……楼主真好运,刚来就有的学)
贴上我的一个,效率很低,我刚入门时写的:(不用set命令哦)
ren *.jpg *.
for /l %%a in (1,1,10000) do (
ren *. a-%%a.jpg 2>nul
if not exist *. exit
)
解释:将所有的jpg文件改为 格式
然后 的for /l %%a 从1到10000
f1 --重命名*. 为 1.jpg 由于系统错误,所以只能重命名出一个1.jpg
f2 --重命名*. 为 2.jpg 因为是ren *. 所以 之前的1.jpg不会被改成2.jpg
并且仍把剩下的提取一个2.jpg 达到了一个个重命名的效果。
f3 f4以此类推
此方法不支持大家用,纯粹是绕弯路……吃饱了撑着,明明精华贴里面有,却硬要
写个自己的。
Last edited by 523066680 on 2008-7-31 at 03:06 PM ]
Short, super short... Speechless... Helpless... Envious...
The code above is already concise to the point where there's not much to explain. If there is, it's the call part... This is a very good example. The poster should master the skills! (Depressed... I don't know this... The poster is really lucky, just came and has something to learn)
Paste one of mine, which is very inefficient. It was written when I just started: (Without using the set command)
ren *.jpg *.
for /l %%a in (1,1,10000) do (
ren *. a-%%a.jpg 2>nul
if not exist *. exit
)
Explanation: Rename all jpg files to format
Then the for /l %%a from 1 to 10000
f1 -- Rename *. to 1.jpg Because of the system error, so only one 1.jpg can be renamed
f2 -- Rename *. to 2.jpg Because it's ren *. so the previous 1.jpg won't be changed to 2.jpg
And still extract one 2.jpg from the remaining to achieve the effect of renaming one by one.
f3 f4 and so on
This method is not supported for everyone to use. It's purely going the long way... Having nothing better to do, obviously there's a精华 post, but still insist on writing one of my own.
Last edited by 523066680 on 2008-7-31 at 03:06 PM ]
|

综合型编程论坛
我的作品索引 |
|
2008-7-28 08:49 |
|
|
23112656
中级用户
  
积分 220
发帖 99
注册 2008-6-26
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
呵呵```谢谢啊```其实我觉得绕弯路是成为高手的捷径啊`
Hehe```Thanks```Actually I think going the long way is the shortcut to becoming an expert ah`
|
|
2008-7-30 23:12 |
|
|
23112656
中级用户
  
积分 220
发帖 99
注册 2008-6-26
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
可是用了2楼的代码为什么数字并不是按照顺序来排列的呢?准确说数字是到100以后才开始正确排列的.100以前的数字都是跳着改名的
But why aren't the numbers arranged in order when using the code from floor 2? To be precise, the numbers start to be arranged correctly only after reaching 100. The numbers before 100 are all renamed in a jumping manner
|
|
2008-7-30 23:31 |
|
|
pusofalse
银牌会员
    
积分 1604
发帖 646
注册 2008-4-13
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
不是跳着改名,而是排列顺序不同,你右键一下,名称排列。
在我电脑上运行正常。
It's not about renaming by jumping, but the different arrangement order. You right - click and arrange the names. It runs normally on my computer.
|

心绪平和,眼藏静谧,无比安稳的火... Purification of soul...Just a false...^_^ |
|
2008-7-31 07:51 |
|
|
studythedos
初级用户
 
积分 91
发帖 45
注册 2007-3-14
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
以前见个批量改的,是先删到回收站的,觉得挺麻烦的,原来这里还有这么简单的啊。。学了。。
I saw a batch - modified one before, which first deleted to the recycle bin, and thought it was quite troublesome. It turns out there is such a simple one here. Learned it..
|
|
2008-7-31 08:45 |
|
|
23112656
中级用户
  
积分 220
发帖 99
注册 2008-6-26
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
Originally posted by pusofalse at 2008-7-31 07:51 AM:
不是跳着改名,而是排列顺序不同,你右键一下,名称排列。
在我电脑上运行正常。
我排列过了还是我说的那样啊,所以我建了2个批,执行完一个后排列不正常,然后再执行第二个就好了,这之间的问题是什么呢?和延时有关系吗?
Originally posted by pusofalse at 2008-7-31 07:51 AM:
It's not renaming by jumping, but the order of arrangement is different. You can right-click and sort by name.
It runs normally on my computer.
I have sorted it, but it's still as I said. So I created 2 batches. After executing one, the arrangement is abnormal, and then executing the second one is fine. What's the problem in between? Is it related to delay?
|
|
2008-8-1 04:33 |
|
|
523066680
银牌会员
     SuperCleaner
积分 2362
发帖 1133
注册 2008-2-2
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
可能……
试试把for %%a in (*.jpg) do (
改成 for /f "tokens=*" %%a in ('dir *.jpg') do (
我觉得有可能是,重命名后,已经被rename过的文件 仍被在for读取
导致重复重命名同一部分文件
但是 在我这里测试的时候 没有出问题
欢迎参考这个帖子: http://www.cn-dos.net/forum/viewthread.php?tid=41846&fpage=2
论坛批处理区置顶的地方 有批处理精华帖
支持楼主下载 好好看,收获很大的
Last edited by 523066680 on 2008-8-1 at 10:54 AM ]
Maybe...
Try changing for %%a in (*.jpg) do (
to for /f "tokens=*" %%a in ('dir *.jpg') do (
I think it's possible that after renaming, the files that have already been renamed are still being read by for, causing the same part of the files to be renamed repeatedly
But when I tested here, there was no problem
Welcome to refer to this post: http://www.cn-dos.net/forum/viewthread.php?tid=41846&fpage=2
There are essential posts of batch processing in the top area of the batch processing section of the forum
Support the building to download, read it carefully, and gain a lot
Last edited by 523066680 on 2008-8-1 at 10:54 AM ]
|

综合型编程论坛
我的作品索引 |
|
2008-8-1 10:40 |
|
|
gxfc
新手上路

积分 17
发帖 11
注册 2006-10-22
状态 离线
|
|
2008-11-19 17:00 |
|