中国DOS联盟论坛

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-11-24 15:21
47,820 topics / 349,938 posts / today 0 new / 48,298 members
DOS批处理 & 脚本技术(批处理室) » [Help] Select and delete time-named files and classify them
Printable Version  3,728 / 41
Floor16 26933062 Posted 2008-05-23 14:59
银牌会员 Posts 879 Credits 2,268
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
Floor17 easonL Posted 2008-05-23 15:13
初级用户 Posts 56 Credits 118 From 南京
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?
Floor18 26933062 Posted 2008-05-23 15:22
银牌会员 Posts 879 Credits 2,268
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?
Floor19 easonL Posted 2008-05-23 15:26
初级用户 Posts 56 Credits 118 From 南京
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
Floor20 26933062 Posted 2008-05-23 15:29
银牌会员 Posts 879 Credits 2,268
How could this be?
Run the following code and paste the result...
:
Floor21 easonL Posted 2008-05-23 15:30
初级用户 Posts 56 Credits 118 From 南京
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?
Floor22 easonL Posted 2008-05-23 15:32
初级用户 Posts 56 Credits 118 From 南京
Originally posted by 26933062 at 2008-5-23 03:29 PM:
How could this be?
Run the following code and post the result...
:
Floor23 26933062 Posted 2008-05-23 15:33
银牌会员 Posts 879 Credits 2,268
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 ]
Floor24 easonL Posted 2008-05-23 15:35
初级用户 Posts 56 Credits 118 From 南京
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
Floor25 26933062 Posted 2008-05-23 15:37
银牌会员 Posts 879 Credits 2,268
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
Floor26 easonL Posted 2008-05-23 15:40
初级用户 Posts 56 Credits 118 From 南京
Wow!!!!!
It's so powerful, it's really fixed!!
Hehe, what's the reason? Can you analyze it?
Floor27 26933062 Posted 2008-05-23 15:51
银牌会员 Posts 879 Credits 2,268
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 ]
Floor28 easonL Posted 2008-05-23 16:00
初级用户 Posts 56 Credits 118 From 南京
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
Floor29 26933062 Posted 2008-05-23 16:10
银牌会员 Posts 879 Credits 2,268
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...

:
Floor30 easonL Posted 2008-05-23 16:13
初级用户 Posts 56 Credits 118 From 南京
Well, thank you, and I'll continue to study! I'll come to you for help if I encounter problems!
I'm very grateful!
Prev  1 2 3  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023