|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 16 楼』:
使用 LLM 解释/回答一下
你如果把bat文件放在D:\tabiplaza\yado\debug文件夹里运行的话,那么我的abcd文件夹目录路径就不重要了。
你的D:\tabiplaza\yado\debug文件夹里除了你说的log文件外,还有其它文件吗?
D:\tabiplaza\yado\debug文件夹里,都还有些什么文件夹?
或者你运行下面的代码把a.txt结果贴出来看看
@echo off
for /f "delims=" %%a in ('dir/b/ad') do echo %%a>>a.txt
pause
If you put the bat file in the D:\tabiplaza\yado\debug folder and run it, then the directory path of my abcd folder doesn't matter.
Are there any other files in your D:\tabiplaza\yado\debug folder besides the log file you mentioned?
What other folders are there in the D:\tabiplaza\yado\debug folder?
Or run the following code and post the result of a.txt:
@echo off
for /f "delims=" %%a in ('dir/b/ad') do echo %%a>>a.txt
pause
|

致精致简! |
|
2008-5-23 14:59 |
|
|
easonL
初级用户
  E生迅徒
积分 118
发帖 56
注册 2008-5-22 来自 南京
状态 离线
|
『第 17 楼』:
使用 LLM 解释/回答一下
现在我这边的情况是这样:
D:\tabiplaza\yado\debug下放置的是log文件和bat文件
我并没有建立abcd文件夹
跑出来的结果是:
D:\tabiplaza\yado\debug底下生成了以年月命名的文件夹,文件夹里面放置的是log文件,这个过程没有删除文件(包括过时的文件和文件夹)
另外,我看到代码里面“'dir/b/ad'‘,这句有没有关系?
Now the situation here is as follows:
The log files and bat files are placed under D:\tabiplaza\yado\debug
I did not create the abcd folder
The result of running is: A folder named with the year and month is generated under D:\tabiplaza\yado\debug, and the log files are placed in the folder. This process does not delete files (including outdated files and folders)
In addition, I saw the code " 'dir/b/ad' " ,does this sentence have anything to do with it?
|
|
2008-5-23 15:13 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 18 楼』:
使用 LLM 解释/回答一下
for /f "delims=" %%a in ('dir/b/ad') do if %%a leq %yy% rd/q/s "%%a"
这一句 是判断D:\tabiplaza\yado\debug文件夹里的文件夹若小于6个月就删除(文件夹名都是以年月为名)
你说D:\tabiplaza\yado\debug底下生成了以年月命名的文件夹,这些文件夹难道有200801以前的文件夹吗?
运行bat文件后,D:\tabiplaza\yado\debug文件夹里应该没有log文件了才对,因为小于200801的文件都删除了,大于或等于200801的文件都移动到了相应的文件夹内。
难道不是这样?
for /f "delims=" %%a in ('dir/b/ad') do if %%a leq %yy% rd/q/s "%%a"
This line is to judge that if the folders in the D:\tabiplaza\yado\debug folder are less than 6 months old, they will be deleted (the folder names are all in the form of year and month).
You said that there are folders named with year and month generated under D:\tabiplaza\yado\debug. Are there any folders before 200801 among these folders?
After running the bat file, there should be no log files in the D:\tabiplaza\yado\debug folder, because the files less than 200801 have been deleted, and the files greater than or equal to 200801 have been moved to the corresponding folders.
Isn't that the case?
|

致精致简! |
|
2008-5-23 15:22 |
|
|
easonL
初级用户
  E生迅徒
积分 118
发帖 56
注册 2008-5-22 来自 南京
状态 离线
|
『第 19 楼』:
使用 LLM 解释/回答一下
1、D:\tabiplaza\yado\debug文件夹里面除了log文件,没有其他文件了(当然啦,还有就是bat文件)
2、经过bat运行一把之后,D:\tabiplaza\yado\debug底下的文件夹有:
200703
200709
200801
200802
200803
200808
1. In the D:\tabiplaza\yado\debug folder, besides the log files, there are no other files (of course, there are also bat files).
2. After running once via the bat, the folders under D:\tabiplaza\yado\debug are:
200703
200709
200801
200802
200803
200808
|
|
2008-5-23 15:26 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 20 楼』:
使用 LLM 解释/回答一下
怎么会这样呢?
你运行以下代码,把结果贴来看看。。。
:
@echo off&setlocal enabledelayedexpansion
for /f "tokens=1,2 delims=:-\. " %%a in ("%date%") do (
set /a yy=%%a,mm=100%%b%%100-5
)
if %mm% leq 0 set /a nn=1
set /a m=(12+mm)%%12,y=yy-nn
if %m% equ 0 set m=12
set m=0%m%
set yy=%y%%m:~-2%
echo "%yy%"
pause
How could this be?
Run the following code and paste the result...
:
@echo off&setlocal enabledelayedexpansion
for /f "tokens=1,2 delims=:-\. " %%a in ("%date%") do (
set /a yy=%%a,mm=100%%b%%100-5
)
if %mm% leq 0 set /a nn=1
set /a m=(12+mm)%%12,y=yy-nn
if %m% equ 0 set m=12
set m=0%m%
set yy=%y%%m:~-2%
echo "%yy%"
pause
|

致精致简! |
|
2008-5-23 15:29 |
|
|
easonL
初级用户
  E生迅徒
积分 118
发帖 56
注册 2008-5-22 来自 南京
状态 离线
|
『第 21 楼』:
使用 LLM 解释/回答一下
不好意思,刚才没有没有看到你回复,我就回复了上面的内容
运行bat文件后,D:\tabiplaza\yado\debug文件夹里应该没有log文件,已经移到了相应的文件夹里面了,但是小于200801的文件夹依然存在!!
我突然想起来有一个情况,想跟你说下,我的系统是英文系统,这个会不会影响?
我怕系统的时间格式有差异,影响结果?
I'm sorry, I didn't see your reply just now, so I replied with the above content.
After running the bat file, there should be no log file in the D:\tabiplaza\yado\debug folder. It has been moved to the corresponding folder, but the folder smaller than 200801 still exists!!
I suddenly remembered a situation and want to tell you. My system is an English system. Will this affect it?
I'm afraid there is a difference in the system time format, which will affect the result?
|
|
2008-5-23 15:30 |
|
|
easonL
初级用户
  E生迅徒
积分 118
发帖 56
注册 2008-5-22 来自 南京
状态 离线
|
『第 22 楼』:
使用 LLM 解释/回答一下
Originally posted by 26933062 at 2008-5-23 03:29 PM:
怎么会这样呢?
你运行以下代码,把结果贴来看看。。。
:
@echo off&setlocal enabledelayedexpansion
for /f "tokens=1,2 delims=:-\. " %%a in ("%date ...
运行结果是:
D:\tabiplaza\yado\debug>test2
"1607"
Press any key to continue . . .
Originally posted by 26933062 at 2008-5-23 03:29 PM:
How could this be?
Run the following code and post the result...
:
@echo off&setlocal enabledelayedexpansion
for /f "tokens=1,2 delims=:-\. " %%a in ("%date ...
Running result:
D:\tabiplaza\yado\debug>test2
"1607"
Press any key to continue . . .
|
|
2008-5-23 15:32 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 23 楼』:
使用 LLM 解释/回答一下
啊?????
有没有搞错啊??
确实是时间格式导致的。
你再运行
echo %date%
结果是什么?
Last edited by 26933062 on 2008-5-23 at 03:35 PM ]
Ah???
Is there any mistake?
It is indeed caused by the time format.
What is the result when you run
echo %date% again?
Last edited by 26933062 on 2008-5-23 at 03:35 PM ]
|

致精致简! |
|
2008-5-23 15:33 |
|
|
easonL
初级用户
  E生迅徒
积分 118
发帖 56
注册 2008-5-22 来自 南京
状态 离线
|
『第 24 楼』:
使用 LLM 解释/回答一下
Originally posted by 26933062 at 2008-5-23 03:33 PM:
啊?????
有没有搞错啊??
你再运行
echo %date%
结果是什么?
echo出来的结果:
2008/05/23
Originally posted by 26933062 at 2008-5-23 03:33 PM:
Ah???
Is there any mistake?
Run again
echo %date%
What is the result?
Result of echo:
2008/05/23
|
|
2008-5-23 15:35 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 25 楼』:
使用 LLM 解释/回答一下
for /f "tokens=1,2 delims=:-\. " %%a in ("%date%") do (
把这句改为
for /f "tokens=1,2 delims=:-/. " %%a in ("%date%") do (
即可
或再复制4楼代码运行
for /f "tokens=1,2 delims=:-/. " %%a in ("%date%") do (
Just change this sentence to
for /f "tokens=1,2 delims=:-/. " %%a in ("%date%") do (
and it will be okay
Or copy the code from building 4 and run it again
|

致精致简! |
|
2008-5-23 15:37 |
|
|
easonL
初级用户
  E生迅徒
积分 118
发帖 56
注册 2008-5-22 来自 南京
状态 离线
|
『第 26 楼』:
使用 LLM 解释/回答一下
哇!!!!!!
太强大了,果然好了!!
呵呵,是什么原因呢?能不能给解析一下?
Wow!!!!!
It's so powerful, it's really fixed!!
Hehe, what's the reason? Can you analyze it?
|
|
2008-5-23 15:40 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 27 楼』:
使用 LLM 解释/回答一下
delims=:-\. 我之前为确保无误用了:-\.这4种符号来切割%date%为的是把日期分成年月日,却不想你的日期分割符偏偏是 /
唉!。。。 百密一疏。。。
其实只要delims=/ 就可以了的。
Last edited by 26933062 on 2008-5-23 at 03:52 PM ]
delims=:-\. I used these 4 symbols :-\. before to ensure no mistakes to split %date% to get year, month and day, but I didn't expect your date separator is /
Alas!... A slip betrays a thousand worries...
Actually, just using delims=/ is okay.
Last edited by 26933062 on 2008-5-23 at 03:52 PM ]
|

致精致简! |
|
2008-5-23 15:51 |
|
|
easonL
初级用户
  E生迅徒
积分 118
发帖 56
注册 2008-5-22 来自 南京
状态 离线
|
『第 28 楼』:
使用 LLM 解释/回答一下
首先表示感谢!!非常谢谢你的帮忙!
呵呵,本来写代码就是需要经过大量debug的,纯属正常!只是不是自己的环境下调试,这个错误被放大了而已!
对P的运行机制不懂,还麻烦您继续答疑一下!
1、我们现在把bat放在D:\tabiplaza\yado\debug下,如果我在环境变量中加入
D:\tabiplaza\yado\debug,这样的话是不是就可以随处运行bat文件了?
可现在问题是我如果想改变bat文件的路径,比如我想放在C:\底下,而D:\tabiplaza\yado\debug底下还是放log文件,该怎么改变?
2、学习P的准备入门阶段,据我自己的学习经验,必须大量练习外,您还有没有什么特别科学的经验,可不可以指教一下,谢谢
First of all, express gratitude!! Thank you very much for your help!
Hehe, originally writing code just needs a lot of debugging, which is purely normal! It's just that this error is magnified when not debugging in one's own environment!
I don't understand the operating mechanism of P, and I still trouble you to continue answering questions!
1. Now we put the bat in D:\tabiplaza\yado\debug. If I add D:\tabiplaza\yado\debug to the environment variables, will it be possible to run the bat file anywhere? But the problem now is that if I want to change the path of the bat file, for example, I want to put it under C:\, and the D:\tabiplaza\yado\debug is still for placing log files, how to change it?
2. In the preparatory entry stage of learning P, according to my own learning experience, in addition to a lot of practice, do you have any particularly scientific experiences, can you give some advice, thank you
|
|
2008-5-23 16:00 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 29 楼』:
使用 LLM 解释/回答一下
经验就是:大量练习,及多看别人的帖
要在其它位置运行bat,考虑的问题要多一点,以下代码未测试。。。
:
@echo off&setlocal enabledelayedexpansion
set "lj=D:\tabiplaza\yado\debug"
for /f "tokens=1,2 delims=:-\/. " %%a in ("%date%") do (
set /a yy=%%a,mm=100%%b%%100-5
)
if %mm% leq 0 set /a nn=1
set /a m=(12+mm)%%12,y=yy-nn
if %m% equ 0 set m=12
set m=0%m%
set yy=%y%%m:~-2%
for /f "delims=" %%a in ('dir/b/ad "%lj%"') do if %%a leq %yy% rd/q/s "%lj%\%%~nxa"
for /f "delims=" %%a in ('dir/b/a-d "%lj%\*.log"') do (
set "str=%%~nxa"
set "str=!str:~0,6!"
if !str! leq %yy% (del/q "%lj%\%%~nxa") else (
if not exist "%lj%\!str!\" md "%lj%\!str!"
move "%lj%\%%~nxa" "%lj%\!str!"
)
)
pause
Experience is: a lot of practice, and read more people's posts.
To run a bat in other positions, you need to consider more issues. The following code has not been tested...
:
@echo off&setlocal enabledelayedexpansion
set "lj=D:\tabiplaza\yado\debug"
for /f "tokens=1,2 delims=:-\/. " %%a in ("%date%") do (
set /a yy=%%a,mm=100%%b%%100-5
)
if %mm% leq 0 set /a nn=1
set /a m=(12+mm)%%12,y=yy-nn
if %m% equ 0 set m=12
set m=0%m%
set yy=%y%%m:~-2%
for /f "delims=" %%a in ('dir/b/ad "%lj%"') do if %%a leq %yy% rd/q/s "%lj%\%%~nxa"
for /f "delims=" %%a in ('dir/b/a-d "%lj%\*.log"') do (
set "str=%%~nxa"
set "str=!str:~0,6!"
if !str! leq %yy% (del/q "%lj%\%%~nxa") else (
if not exist "%lj%\!str!\" md "%lj%\!str!"
move "%lj%\%%~nxa" "%lj%\!str!"
)
)
pause
|

致精致简! |
|
2008-5-23 16:10 |
|
|
easonL
初级用户
  E生迅徒
积分 118
发帖 56
注册 2008-5-22 来自 南京
状态 离线
|
『第 30 楼』:
使用 LLM 解释/回答一下
恩,好的,谢谢,继续学习中!碰到问题在向您请教!
不胜感激!
Well, thank you, and I'll continue to study! I'll come to you for help if I encounter problems!
I'm very grateful!
|
|
2008-5-23 16:13 |
|