|
easonL
初级用户
  E生迅徒
积分 118
发帖 56
注册 2008-5-22 来自 南京
状态 离线
|
『第 31 楼』:
使用 LLM 解释/回答一下
银牌会员 【26933062】看见了的话,帮我完善下!!!!谢谢
那天测试的时候,漏了一个case,就是比如现在是6月份了,那么我们应该将200801前的文件和文件夹删除!
但是现在的情况是这样的,计算出来的日期是200701前的东西删除!这不对
好像是这段命令的原因,帮忙分析下(好像if %mm% gtr 0 这种情况也做了日期转换了)
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%
各位大虾,帮帮忙,谢谢
Silver member 【26933062】, if you see this, please help improve it!!! Thanks
When testing that day, a case was missed, that is, now it is June, so we should delete the files and folders before 200801!
But the current situation is that the things before 200701 are deleted! This is incorrect
It seems to be the reason for this section of the command, help analyze it (it seems that the date conversion was also done for the situation like if %mm% gtr 0)
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%
Dear experts, please help, thanks
|
|
2008-5-26 15:26 |
|
|
easonL
初级用户
  E生迅徒
积分 118
发帖 56
注册 2008-5-22 来自 南京
状态 离线
|
『第 32 楼』:
使用 LLM 解释/回答一下
Originally posted by 26933062 at 2008-5-23 04:10 PM:
经验就是:大量练习,及多看别人的帖
要在其它位置运行bat,考虑的问题要多一点,以下代码未测试。。。
:
@echo off&setlocal enabledelayedexpansi ...
这个是最终的P
Originally posted by 26933062 at 2008-5-23 04:10 PM:
The experience is: a large number of practices, and read more others' posts
To run a bat in other positions, more issues need to be considered. The following code is not tested...
:
@echo off&setlocal enabledelayedexpansi ...
This is the final P
|
|
2008-5-26 15:32 |
|
|
easonL
初级用户
  E生迅徒
积分 118
发帖 56
注册 2008-5-22 来自 南京
状态 离线
|
『第 33 楼』:
使用 LLM 解释/回答一下
呵呵,自己搞明白了
在if %mm% leq 0 set /a nn=1前面多添加一种case就好了
添加:
if %mm% gtr 0 set /a nn=0
Hehe, I figured it out by myself. Just add one more case before if %mm% leq 0 set /a nn=1. Add: if %mm% gtr 0 set /a nn=0
|
|
2008-5-26 15:39 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 34 楼』:
使用 LLM 解释/回答一下
Originally posted by easonL at 2008-5-26 15:39:
呵呵,自己搞明白了
在if %mm% leq 0 set /a nn=1前面多添加一种case就好了
添加:
if %mm% gtr 0 set /a nn=0
那样是不对的,
改这里
for /f "tokens=1,2 delims=:-\/. " %%a in ("%date%") do (
set /a yy=%%a,mm=100%%b%%100- 5
)
Originally posted by easonL at 2008-5-26 15:39:
Hehe, I figured it out myself.
Just add another case before if %mm% leq 0 set /a nn=1.
Add:
if %mm% gtr 0 set /a nn=0
That's incorrect.
Modify here:
for /f "tokens=1,2 delims=:-\/. " %%a in ("%date%") do (
set /a yy=%%a,mm=100%%b%%100- 5
)
|

致精致简! |
|
2008-5-26 15:42 |
|
|
easonL
初级用户
  E生迅徒
积分 118
发帖 56
注册 2008-5-22 来自 南京
状态 离线
|
『第 35 楼』:
使用 LLM 解释/回答一下
Originally posted by 26933062 at 2008-5-26 03:42 PM:
那样是不对的,
改这里
for /f "tokens=1,2 delims=:-\/. " %%a in ("%date%") do (
set /a yy=%%a,mm=100%%b%%100-5
)
啊??您好像没有改什么嘛,跟原来的对比,没有看出来呢,呵呵
Originally posted by 26933062 at 2008-5-26 03:42 PM:
That's not right,
Modify here
for /f "tokens=1,2 delims=:-\/. " %%a in ("%date%") do (
set /a yy=%%a,mm=100%%b%%100-5
)
Ah? You don't seem to have changed anything. Comparing with the original, I can't see it, heh heh
|
|
2008-5-26 15:58 |
|
|
easonL
初级用户
  E生迅徒
积分 118
发帖 56
注册 2008-5-22 来自 南京
状态 离线
|
『第 36 楼』:
使用 LLM 解释/回答一下
银牌会员 【26933062】大虾,还有顺便把我那样改为什么不对,给稍微解析一下,拜托了!
Silver member 【26933062】Big shot, and by the way, why is my modification like that incorrect? Please give a little analysis, please!
|

無求一生光輝 唯朢鬥志不會斷 |
|
2008-5-26 16:16 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 37 楼』:
使用 LLM 解释/回答一下
计算部分好像确实有误,容我想想。。
It seems there is indeed an error in the calculation part. Let me think about it.
|

致精致简! |
|
2008-5-26 16:20 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 38 楼』:
使用 LLM 解释/回答一下
没错啊!
你现在是什么问题?
That's right! What problem are you having now?
|

致精致简! |
|
2008-5-26 16:25 |
|
|
easonL
初级用户
  E生迅徒
积分 118
发帖 56
注册 2008-5-22 来自 南京
状态 离线
|
『第 39 楼』:
使用 LLM 解释/回答一下
有错的!我描述下问题:
假如现在是6月份了,那么我们应该将200801以前的文件和文件夹删除,对吧?
可是现在不是这样的,结果是只将200701之前的文件和文件夹删除了。
时间计算那边出了问题,貌似!您给看看
There is a mistake! Let me describe the problem:
If it's June now, then we should delete the files and folders before 200801, right?
But it's not like that now. The result is that only the files and folders before 200701 are deleted.
There seems to be a problem with the time calculation! You can take a look
|

無求一生光輝 唯朢鬥志不會斷 |
|
2008-5-26 16:30 |
|
|
easonL
初级用户
  E生迅徒
积分 118
发帖 56
注册 2008-5-22 来自 南京
状态 离线
|
『第 40 楼』:
使用 LLM 解释/回答一下
等一下,我再仔细确认下!!
Wait a minute, I'll double - check it carefully!
|

無求一生光輝 唯朢鬥志不會斷 |
|
2008-5-26 16:33 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 41 楼』:
使用 LLM 解释/回答一下
怎么可能?
你测试以下代码。。。
:
@echo off
::下面是假设当前日期为2008年6月,可自行修改测试
set date=2008/6
::::::::::::::::::::::::::::::
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.&echo 删除 %yy% 以前的文件(含%yy%)
echo.&pause
How is that possible?
You test the following code...
:
@echo off
::The following is assuming the current date is June 2008, you can modify it yourself for testing
set date=2008/6
::::::::::::::::::::::::::::::
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.&echo Delete files before %yy% (including %yy%)
echo.&pause
|

致精致简! |
|
2008-5-26 16:35 |
|
|
easonL
初级用户
  E生迅徒
积分 118
发帖 56
注册 2008-5-22 来自 南京
状态 离线
|
『第 42 楼』:
使用 LLM 解释/回答一下
汗~~~~~~~~~~
怎么现在测试的结果跟刚才不一样了!应该是没有问题的!
真的对不起啊!浪费你的时间了
不过真的很奇怪啊,我自己在看看刚才怎么回事
Swe sweat~~~~~~~~~~
Why is the test result different from just now! It should be no problem!
I'm really sorry! I wasted your time
But it's really strange ah, I'll take a look at what happened just now by myself
|

無求一生光輝 唯朢鬥志不會斷 |
|
2008-5-26 16:38 |
|