Find files that meet the time range with batch processing
Origin:
I saw Brother shijianxin's question, which was how to find files created in a certain time period. Before starting, the first thing I thought of was Windows Resource Kits or forfiles.exe under 2003. After looking at the help, I was very disappointed. forfiles can only select files that are greater than or equal to or less than or equal to a certain date, and cannot select files in a certain time period. It seems I have to write a batch processing myself. I wanted to find the starting point of the problem, but I found it difficult. I thought of using Ritchie Lawrence's DateToDays function, how would the efficiency and speed be? I immediately denied this plan. Then I thought of using forfiles to generate a file list greater than and less than a certain date respectively, and then take the overlapping parts of these two files. The efficiency and speed are still not very good. Then I thought, so there is the following script.
Description: This is the simplest version, only the main part of the code, and it is also relatively easy to understand, so I will post it first. I will improve it into a practical batch program later.
Usage: filedate YY-MM-DD YY-MM-DD, parameter 1 is the start date, parameter 2 is the end date, for example: 2006-06-30 2006-07-09
[ Last edited by 无奈何 on 2006-8-3 at 22:57 ]
Origin:
I saw Brother shijianxin's question, which was how to find files created in a certain time period. Before starting, the first thing I thought of was Windows Resource Kits or forfiles.exe under 2003. After looking at the help, I was very disappointed. forfiles can only select files that are greater than or equal to or less than or equal to a certain date, and cannot select files in a certain time period. It seems I have to write a batch processing myself. I wanted to find the starting point of the problem, but I found it difficult. I thought of using Ritchie Lawrence's DateToDays function, how would the efficiency and speed be? I immediately denied this plan. Then I thought of using forfiles to generate a file list greater than and less than a certain date respectively, and then take the overlapping parts of these two files. The efficiency and speed are still not very good. Then I thought, so there is the following script.
Description: This is the simplest version, only the main part of the code, and it is also relatively easy to understand, so I will post it first. I will improve it into a practical batch program later.
Usage: filedate YY-MM-DD YY-MM-DD, parameter 1 is the start date, parameter 2 is the end date, for example: 2006-06-30 2006-07-09
Helplessly posted on 2006-07-31 21:48
- @echo off
- if "%1" NEQ "$" (
- set Bdate=%1
- set Edate=%2
- for /f "tokens=1,2 delims=§" %%a in ('"%~0" $^|sort') do (
- call :sub "%%a" "%%b"
- )
- ) else (
- for %%i in (*) do echo %%~ti§%%i
- echo.%Bdate% 00:00
- echo.%Edate% 99:99
- )
- goto :EOF
- :sub
- if "%~1" == "%Edate% 99:99" set flag=0
- if "%flag%" == "1" echo."%~2"
- if "%~1" == "%Bdate% 00:00" set flag=1
- goto :EOF
[ Last edited by 无奈何 on 2006-8-3 at 22:57 ]
☆开始\运行 (WIN+R)☆
%ComSpec% /cset,=何奈无── 。何奈可无是原,事奈无做人奈无&for,/l,%i,in,(22,-1,0)do,@call,set/p= %,:~%i,1%<nul&ping/n 1 127.1>nul
%ComSpec% /cset,=何奈无── 。何奈可无是原,事奈无做人奈无&for,/l,%i,in,(22,-1,0)do,@call,set/p= %,:~%i,1%<nul&ping/n 1 127.1>nul

DigestI