|
zxllxz
新手上路

积分 4
发帖 2
注册 2005-10-12
状态 离线
|
『楼 主』:
(已结)ren a %date%.txt
使用 LLM 解释/回答一下
需要对产生的文件a 进行改名ren a %date%.txt
不能实现,有什么语法错误,目的是对每天产生的a改名为当天时间命名的文本文件.
---------- Edited by willsort ----------
解决方案如下:
ren a "%date%.txt" ——2楼
此种方法产生的文件名会包含星期计数,想去掉它取决于你系统中%date%的日期格式,如果是类似 “2005-10-15 星期六”,可以使用
ren a "%date:~0,10%.txt" ——2楼
如果是类似 “Sat 2005-10-15” 的格式,则需要使用
ren a "%date:~-10%.txt"
如果是其它的日期格式还可能需要另作处理。
这仅仅是NT系列平台下的NTVDM环境(DOS窗口)中才能使用的方法,在MSDOS6.22/7.10/Win9x下需要使用另外的方案,请搜索本论坛。
---------- Edited by willsort ----------
Last edited by willsort on 2005-10-15 at 18:27 ]
Need to rename the generated file a, using ren a %date%.txt doesn't work. What is the syntax error? The purpose is to rename a generated every day to a text file named with the current day's time.
---------- Edited by willsort ----------
The solution is as follows:
ren a "%date%.txt" ——Floor 2
The file name generated by this method will contain the week count. To remove it depends on the date format of %date% in your system. If it is like "2005-10-15 Saturday", you can use
ren a "%date:~0,10%.txt" ——Floor 2
If it is like "Sat 2005-10-15", then you need to use
ren a "%date:~-10%.txt"
If it is other date formats, additional processing may be needed.
This is only a method that can be used in the NTVDM environment (DOS window) of the NT series platform. Under MSDOS6.22/7.10/Win9x, another solution is needed. Please search this forum.
---------- Edited by willsort ----------
Last edited by willsort on 2005-10-15 at 18:27 ]
|
|
2005-10-12 13:49 |
|
|
无奈何
荣誉版主
      
积分 1338
发帖 356
注册 2005-7-15
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
试试这样 ren a "%date%.txt"
事实上这样,并不一定获得如 “2005-10-12”这样得格式,这与日期格式跟区域设置有关。如果想获得如上所示的格式,请用下面的方法:
ren a "%date:~0,10%.txt"
Try this: ren a "%date%.txt"
In fact, like this, it may not necessarily get a format like "2005-10-12", which is related to the date format and regional settings. If you want to get the format shown above, please use the following method:
ren a "%date:~0,10%.txt"
|
|
2005-10-12 15:14 |
|
|
zxllxz
新手上路

积分 4
发帖 2
注册 2005-10-12
状态 离线
|
|
2005-10-12 15:54 |
|
|
不得不爱
超级版主
         我爱DOS
积分 5310
发帖 2044
注册 2005-9-26 来自 四川南充
状态 离线
|
|
2005-10-12 16:27 |
|
|
JonePeng
金牌会员
      D◎$ Fαп
积分 4562
发帖 1883
注册 2004-1-19 来自 广东广州
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
Originally posted by qwe1234567 at 2005-10-12 16:27:
不知为什么要把%date%.txt用“”影起来才能正确?
在CMD下,你试试运行 echo %date% 看看结果是什么?作为斑竹,你应该看得出来是什么原因的了,呵呵。
Originally posted by qwe1234567 at 2005-10-12 16:27:
I don't know why I need to enclose %date%.txt with "" to make it work correctly?
In CMD, try running echo %date% and see what the result is? As a moderator, you should be able to see why, heh heh.
|

----====≡≡≡≡ 我的至爱,永远是MSDOS!≡≡≡≡====----
|
|
2005-10-12 16:41 |
|
|
willsort
元老会员
         Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
Re 无奈何:
%date:~0,10%v 仍然无法避免因为日期格式或者代码页不同所造成的不兼容状况。而且在XP的环境下,某些日期变量格式的变化出人意料。比如下面的命令行截取。其中的“星期三”在窗口字体为“点阵字体”时会显示为“???”,为 “Lucida Console” 时正常显示。
C:\Documents and Settings\wil>chcp 437
Active code page: 437
C:\Documents and Settings\wil>echo %date%
星期三 2005-10-12
Re qwe1234567 :
作为论坛版主,积极热情是第一要素,管理经验排是第二要素,技术水平只能是第三要素。qwe1234567 兄这几天来的发帖率已经充分证实了第一要素的具备,第二要素我们会拭目以待,第三要素则可能需要一段时间的培养和积累。
在此,我希望 qwe1234567 兄能继续保持这种对DOS和中国DOS联盟的热情,为我们论坛的持久发展做出贡献!
Re 无奈何:
The %date:~0,10%v still cannot avoid incompatibility situations caused by different date formats or code pages. Moreover, in the XP environment, some changes in date variable formats are unexpected. For example, the following command line interception. The "Wednesday" will be displayed as "???" when the window font is "raster font", and normally displayed when it is "Lucida Console".
C:\Documents and Settings\wil>chcp 437
Active code page: 437
C:\Documents and Settings\wil>echo %date%
星期三 2005-10-12
Re qwe1234567 :
As a forum moderator, enthusiasm is the first element, management experience is the second element, and technical level can only be the third element. Brother qwe1234567's posting rate in the past few days has fully confirmed the possession of the first element, we will wait and see for the second element, and the third element may need a period of cultivation and accumulation.
Here, I hope that Brother qwe1234567 can continue to maintain this enthusiasm for DOS and the China DOS Union, and make contributions to the sustainable development of our forum!
|

※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2005-10-12 23:04 |
|
|
无奈何
荣誉版主
      
积分 1338
发帖 356
注册 2005-7-15
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
to willsort
我试了一下当代码页: 为437时,不能显示中文,当字体设为“Lucida Console”汉字过长时也不能完整显示,选中汉字时还会出现选中半个汉字的时候。更改代码页后确实有问题。但我想不通使用中文 XP 处理中文文档更改其他代码页的必要性。
to willsort
I tried when the code page is set to 437, it can't display Chinese. When the font is set to "Lucida Console", long Chinese characters can't be fully displayed, and when selecting Chinese characters, there will be a situation where half a Chinese character is selected. There are indeed problems after changing the code page. But I can't figure out the necessity of changing other code pages when using Chinese XP to handle Chinese documents.
|
|
2005-10-13 00:23 |
|
|
willsort
元老会员
         Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
Re 无奈何:
在中文XP命令行环境中,仍然有许多使用437代码页的可能,比如运行16位DOS程序,代码页的自动切换;比如我现在的中文XP环境,使用运行CMD的方式进入命令行,便默认是437代码页,尽管这有些古怪。
Re 无奈何:
In the Chinese XP command line environment, there are still many possibilities of using the 437 code page, such as running 16-bit DOS programs, automatic switching of code pages; for example, in my current Chinese XP environment, entering the command line by running CMD, it defaults to the 437 code page, although this is a bit strange.
|

※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2005-10-13 00:51 |
|
|
chenhui530
高级用户
   
积分 772
发帖 273
注册 2004-10-23
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
在XP中使用
for /f "tokens=1,2,3 delims=- " %a in ('date /t') do ren a %a%b.txt
In XP, use
for /f "tokens=1,2,3 delims=- " %a in ('date /t') do ren a %a%b.txt
|

http://www.msfans.net/bbs/ |
|
2005-10-13 11:27 |
|