|
piziliu2004
中级用户
   过度热情
积分 321
发帖 139
注册 2006-3-21
状态 离线
|
|
2006-6-12 11:24 |
|
|
wydos
中级用户
  
积分 304
发帖 117
注册 2006-4-4
状态 离线
|
『第 17 楼』:
提取txt文件的第一行內容给此文件重命名!问题 !麻煩高手解
使用 LLM 解释/回答一下
如何提取txt文件的第一行內容,并用此行内容给此文件重命名?
可不可以一次处理多个文件?
How to extract the content of the first line of a txt file and use this line content to rename the file? Can you process multiple files at once?
|
|
2006-6-12 12:44 |
|
|
3742668
荣誉版主
      
积分 2013
发帖 718
注册 2006-2-18
状态 离线
|
『第 18 楼』:
使用 LLM 解释/回答一下
如何提取txt文件的第一行內容,并用此行内容给此文件重命名?
可不可以一次处理多个文件?
以下代码基本上能满足你的要求:
@echo off
setlocal ENABLEDELAYEDEXPANSION
for %%i in (%*) do (
set /p filename=<%%i
ren %%i "!filename!%%~xi"
)
endlocal
###
How to extract the content of the first line of a txt file and use this line of content to rename this file?
Can multiple files be processed at once?
###
The following code basically meets your requirements:
@echo off
setlocal ENABLEDELAYEDEXPANSION
for %%i in (%*) do (
set /p filename=<%%i
ren %%i "!filename!%%~xi"
)
endlocal
|
|
2006-6-12 17:51 |
|
|
wydos
中级用户
  
积分 304
发帖 117
注册 2006-4-4
状态 离线
|
『第 19 楼』:
使用 LLM 解释/回答一下
先谢谢版主了!
但好象不行!
能不能解释一下每行代码的作用,谢谢!!!
First, thank you to the moderator!
But it doesn't seem to work!
Can you explain the function of each line of code, thank you!!!
|
|
2006-6-12 21:30 |
|
|
wydos
中级用户
  
积分 304
发帖 117
注册 2006-4-4
状态 离线
|
『第 20 楼』:
使用 LLM 解释/回答一下
我把"%*"改为"*.txt" 就可以了,但对于带有空格文件名的文件不起作用,希望版主能不能改进一下。
还有,我还是不理解代码的意思,版主能不能再解释一下?
谢谢!!
I changed "%*" to "*.txt", but it doesn't work for files with space in the file name. I hope the moderator can improve it.
Also, I still don't understand the meaning of the code. Can the moderator explain it again?
Thanks!
|
|
2006-6-12 21:52 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 21 楼』:
使用 LLM 解释/回答一下
如果文件名带有空格,和路径带有空格的解决办法是一样的,加引号就可以了。
If the file name has spaces, the solution is the same as when the path has spaces, just add quotes.
|
|
2006-6-12 22:35 |
|
|
3742668
荣誉版主
      
积分 2013
发帖 718
注册 2006-2-18
状态 离线
|
『第 22 楼』:
使用 LLM 解释/回答一下
先谢谢版主了!
但好象不行!
能不能解释一下每行代码的作用,谢谢!!!
我把"%*"改为"*.txt" 就可以了,但对于带有空格文件名的文件不起作用,希望版主能不能改进一下。 ...
运行时需要带参数,在我这测试可以处理带空格的情况。set /p filename=<%%i用来读取文本的第一行内容。几条命令都很简单,你参照 帮助与支持 应该能自己看明白的。你可以在sendto目录下建立该批处理的快捷方式,这样就可以直接用鼠标选定批量改名了。
Thanks to the moderator first!
But it doesn't seem to work!
Can you explain the function of each line of code, thank you!!!
I changed "%*" to "*.txt" and it works, but it doesn't work for files with space in the file name. I hope the moderator can improve it. ...
It needs parameters when running, and it can handle cases with spaces in my test. set /p filename=<%%i is used to read the content of the first line of the text. Several commands are very simple, you can refer to Help and Support and should be able to understand it yourself. You can create a shortcut of this batch processing in the sendto directory, so that you can directly select batch renaming with the mouse.
|
|
2006-6-13 11:44 |
|
|
wydos
中级用户
  
积分 304
发帖 117
注册 2006-4-4
状态 离线
|
『第 23 楼』:
使用 LLM 解释/回答一下
今天研究了一下,基本上弄懂了。
不过还是有点疑问,想请教版主。就是“%*”是不是指“*.*"?你说的参数也是不是指“*.*"?若我要修改txt,就可输入:”1 *.txt",我理解得对不对?
还有for语句的“do ( )"用法我还是第一次见到(就是do后面带个”()“),帮助与支持 上面好象都没介绍,能不介绍一下他的用法 。
Today I studied it and basically understood it.
But there are still some doubts and I want to ask the moderator. Is "%*" referring to "*.*"? Are the parameters you mentioned also referring to "*.*"? If I want to modify txt, I can input: "1 *.txt", is my understanding correct?
Also, the usage of "do ( )" in the for statement is something I've seen for the first time (that is, "()" after do). There doesn't seem to be an introduction in Help and Support. Can you introduce its usage?
|
|
2006-6-13 19:25 |
|
|
bagpipe
银牌会员
     DOS联盟捡破烂的
积分 1144
发帖 425
注册 2005-10-20 来自 北京
状态 离线
|
『第 24 楼』:
使用 LLM 解释/回答一下
%*请查看一下CALL /?帮助,这个是表示批处理所有的参数,我想楼上测试的时候也是不清楚这个而错的
Please check the CALL /? help. This means all parameters of the batch processing. I think the person upstairs made a mistake because they were not clear about this.
|
|
2006-6-14 09:59 |
|
|
wydos
中级用户
  
积分 304
发帖 117
注册 2006-4-4
状态 离线
|
『第 25 楼』:
使用 LLM 解释/回答一下
谢谢 24 楼!
今天凑巧在CALL /?帮助中看见,终于明白了!!!
但是for语句的“do ( )"用法,哪里有介绍,24 楼能不能解答一下,谢谢!!!
Thanks to post 24!
I happened to see in the CALL /? help today and finally understand!!!
But where is the introduction to the "do ( )" usage of the for statement? Can post 24 answer it, thanks!!!
|
|
2006-6-14 14:19 |
|