![]() |
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-08-04 08:05 |
48,038 topics / 350,123 posts / today 0 new / 48,251 members |
| DOS批处理 & 脚本技术(批处理室) » A new problem: it can run in XP—but why can't it run in 2K? why? |
| Printable Version 940 / 13 |
| Floor1 9389381 | Posted 2007-04-21 09:59 |
| 新手上路 Posts 8 Credits 18 | |
|
How can I use the contents of a TXT document as the name of a new folder
For example, on my computer under d: there is a 123.txt, and its contents are 120304. How can I create a new folder named 120304?? Help!! 'Post #10': A new problem: it can run in XP—but why can't it run in 2K? why? @echo off set /a tm1=%date:~0,4% set /a tm2=%date:~5,2% set /a tm3=%date:~8,2% set /a number=%tm1%*10000+%tm2%*100+%tm3% if not exist D:\beifen.txt echo %number%>D:\beifen.txt Changed to BAT format. When run in XP it generates beifen.txt with the current date as the content. But in 2K the content becomes echo is off So depressing Also, %tm2% and so on are octal. When it gets to month 08 or 09, or day 08 or 09, it won't work.. how do I change it What I originally wanted was to create a TXT document with the current date as its content, and have it run in 2K... ...help [ Last edited by 9389381 on 2007-4-22 at 05:43 PM ] |
|
| Floor2 9389381 | Posted 2007-04-21 13:29 |
| 新手上路 Posts 8 Credits 18 | |
|
I need to use a for statement, but I can't get it to work
help smile |
|
| Floor3 lxmxn | Posted 2007-04-21 18:34 |
| 版主 Posts 4,938 Credits 11,386 | |
|
To 9389381:
First assign the contents of the 123.txt file to a variable, then create this folder. For example: |
|
| Floor4 9389381 | Posted 2007-04-22 06:09 |
| 新手上路 Posts 8 Credits 18 | |
|
I tried it, it works, thanks lx...
…^_^ |
|
| Floor5 htysm | Posted 2007-04-22 08:43 |
| 高级用户 Posts 415 Credits 866 | |
|
Brother lxmxn, can you explain why you don't just use "md %%a", but instead use "set dirname=%%a" and then "md "%dirname%""? Is there any difference between the two?
|
|
| Floor6 9389381 | Posted 2007-04-22 11:36 |
| 新手上路 Posts 8 Credits 18 | |
| Floor7 lxmxn | Posted 2007-04-22 12:12 |
| 版主 Posts 4,938 Credits 11,386 | |
Originally posted by htysm at 2007-4-21 19:43: First, so the OP can understand the idea; second, there may be a problem with spaces. |
|
| Floor8 lxmxn | Posted 2007-04-22 12:14 |
| 版主 Posts 4,938 Credits 11,386 | |
| Floor9 9389381 | Posted 2007-04-23 03:18 |
| 新手上路 Posts 8 Credits 18 | |
| Floor10 9389381 | Posted 2007-04-23 06:34 |
| 新手上路 Posts 8 Credits 18 | |
|
@echo off
set /a tm1=%date:~0,4% set /a tm2=%date:~5,2% set /a tm3=%date:~8,2% set /a number=%tm1%*10000+%tm2%*100+%tm3% if not exist D:\beifen.txt echo %number%>D:\beifen.txt Changed to BAT format. When run in XP it generates beifen.txt with the current date as the content. But in 2K the content becomes echo is off So depressing Also, %tm2% and so on are octal. When it gets to month 08 or 09, or day 08 or 09, it won't work.. how do I change it What I originally wanted was to create a TXT document with the current date as its content, and have it run in 2K... ...help |
|
| Floor11 9389381 | Posted 2007-04-23 07:17 |
| 新手上路 Posts 8 Credits 18 | |
|
I'm bumping bumping bumping bumping bumping bumping
|
|
| Floor12 lxmxn | Posted 2007-04-23 09:30 |
| 版主 Posts 4,938 Credits 11,386 | |
|
Re 9389381:
This may be because the format of the %date% variable is different between 2000 and XP. You can run echo %date% under 2000 and XP respectively, then post the results here and see what is different about the format. You can refer to this thread http://www.cn-dos.net/forum/viewthread.php?tid=24829&fpage=1&highlight=2000%2Bver%2Blxmxn |
|
| Floor13 flyinspace | Posted 2007-04-23 11:08 |
| 银牌会员 Posts 517 Credits 1,206 | |
|
This problem has already been explained before...
The difference between 2000 and XP is: 2000: weekday month. xp: month weekday. |
|
| Floor14 9389381 | Posted 2007-04-25 12:03 |
| 新手上路 Posts 8 Credits 18 | |
|
I know there was a bit of a problem with that digit position,
thanks to all the experts ……^_^ |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |