![]() |
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-09-15 12:45 |
47,812 topics / 349,917 posts / today 0 new / 48,268 members |
| DOS批处理 & 脚本技术(批处理室) » How to find all files created between 17:00 and 17:25 in one day? |
| Printable Version 4,221 / 16 |
| Floor1 anqing | Posted 2006-11-26 07:33 |
| 高级用户 Posts 413 Credits 859 | |
|
How to find all files created between 17:00 and 17:25 in one day?
@echo off set /p d=Please enter the full path: set /p start_time=Please enter the start time of the file creation: set /p end_time=Please enter the end time of the file creation: for /f "tokens=3,*" %%i in ('dir /a-d/od/t:C "%d%" ^| findstr /b /c:"%start_time%" /c:"%end_time%"') do (echo %%j>>d:\22.txt) pause I know this part. I don't know how to find within a certain time range. Can anyone help me modify it? |
|
| Floor2 lxmxn | Posted 2006-11-26 08:40 |
| 版主 Posts 4,938 Credits 11,386 | |
|
Try this, each input should be standard, date example: 2006-11-25, time example (24-hour system): 09:20, 23:50 [ Last edited by lxmxn on 2006-11-27 at 10:21 AM ] |
|
| Floor3 tianzizhi | Posted 2006-11-26 08:58 |
| 高级用户 Posts 214 Credits 623 | |
|
I tried it, but couldn't find the result. The code should be modified further.
|
|
| Floor4 lxmxn | Posted 2006-11-26 09:14 |
| 版主 Posts 4,938 Credits 11,386 | |
|
Re tianzizhi : No way, I tried it and it worked. Unless the date or time you entered is in the wrong format, or there are no files within the time or date you specified. [ Last edited by lxmxn on 2006-11-26 at 09:15 AM ] |
|
| Floor5 不得不爱 | Posted 2006-11-26 09:15 |
| 超级版主 Posts 2,044 Credits 5,310 From 四川南充 | |
|
```batch
@echo off set/p d_=Please enter the path to be searched (default current folder): :error set/p date_=Please enter the creation date of the file to be queried: if not defined date_ goto error set/p time1=Enter the start time: if not defined time1 goto error set/p time2=Please enter the end time: if not defined time2 goto error cls echo Search results:&&echo; for /f "tokens=1,2,4*" %%a in ('dir /a-d/od/tc "%d_%" ^| find "%date_%"') do if %%b geq %time1% if not %%b geq %time2% echo %%c pause ``` |
|
| Floor6 anqing | Posted 2006-11-26 09:28 |
| 高级用户 Posts 413 Credits 859 | |
| Floor7 anqing | Posted 2006-11-26 09:54 |
| 高级用户 Posts 413 Credits 859 | |
|
The creation time of my file is: 16:16:48. I set the start time to 16:15 and the end time to 16:17. As a result, no file was found. But if I set the start time to 16:14, I can find it. Why is that?
I created a new file again. No matter how I set the time, I can find it. Then, I set the time as above again, and as a result, I found it. I think DOS is sometimes unstable, just like an operating system. Actually, DOS is also a kind of operating system, right? I don't know if this understanding is correct. In addition, I want to perform a time period search for files on the entire disk, such as drive C or D. How should I add code? [ Last edited by anqing on 2006-11-26 at 10:20 AM ] |
|
| Floor8 anqing | Posted 2006-11-26 10:06 |
| 高级用户 Posts 413 Credits 859 | |
|
In addition, if I want to search in the C drive, this p can't find it either
|
|
| Floor9 anqing | Posted 2006-11-27 06:34 |
| 高级用户 Posts 413 Credits 859 | |
|
I want to search for files in a time period on the entire disk, such as drive C or D. How to add code?
Waited a day, why no one answers? |
|
| Floor10 3742668 | Posted 2006-11-27 13:01 |
| 荣誉版主 Posts 718 Credits 2,013 | |
|
The above is an example of finding files created on drive D between 20:00 and 23:00 on November 26, 2006. You can specify the drive letter, directory, and other filtering conditions by yourself. P.S: If you search the entire disk, it may run for too long and cause "not responding" (when the number of files is large). |
|
| Floor11 anqing | Posted 2006-11-27 21:59 |
| 高级用户 Posts 413 Credits 859 | |
|
Thank you, moderator. I want to implement searching the entire drive letter within a specified time period in the above batch processing.
|
|
| Floor12 anqing | Posted 2006-11-27 22:24 |
| 高级用户 Posts 413 Credits 859 | |
|
@echo off
set/p d_=Please enter the path to be searched (default current folder): set/p date_=Please enter the creation date of the file to be queried: if not defined date_ goto error set/p time1=Enter start time: if not defined time1 goto error set/p time2=Please enter end time: if not defined time2 goto error cls echo Search results:&&echo; for /f "skip=5 tokens=1,2,4*" %%a in ('dir /a-d/s/od/tc "%d_%" ^| find "%date_%"') do ( if %%b geq %time1% if not %%b geq %time2% ( echo %%c ) ) pause goto :eof :error echo Input error pause To modify it to search for files created in the entire drive letter and specified paths, you can change "%d_%" to "D:\" (assuming you want to search drive D, adjust according to actual situation) and handle the input to support both entire drive and specific paths. For example: @echo off set /p d_=Please enter the path to be searched (enter the drive letter directly to search the entire drive, such as D:): if "%d_"=="" set d_=. set/p date_=Please enter the creation date of the file to be queried: if not defined date_ goto error set/p time1=Enter start time: if not defined time1 goto error set/p time2=Please enter end time: if not defined time2 goto error cls echo Search results:&&echo; for /f "skip=5 tokens=1,2,4*" %%a in ('dir /a-d/s/od/tc "%d_%" ^| find "%date_%"') do ( if %%b geq %time1% if not %%b geq %time2% ( echo %%c ) ) pause goto :eof :error echo Input error pause |
|
| Floor13 zhoung0 | Posted 2007-01-11 04:17 |
| 初级用户 Posts 18 Credits 54 | |
|
lxmxn..If the file that meets the conditions contains spaces, echo %%c can only display part of it..Should use echo %%c %%d bar.
@echo off set /p d_=Please enter the path to be searched (default current folder): if not defined d_ (set d_=%cd%) echo The query path has been set to %d_% set /p date_=Please enter the creation date of the file to be queried: if not defined date_ (for /f %%a in ("%date%") do (set date_=%%a)) echo The file with the creation date %date_% has been set. set /p time1=Enter the start time: if not defined time1 (set time1=00:00) set /p time2=Enter the end time: if not defined time2 (set time2=24:00) cls echo Search results: && echo. for /f "tokens=1,2,3,4*" %%a in ('dir /a-d/s/od/tc "%d_%" ^| find "%date_%"') do ( if %%b geq %time1% ( if %%b leq %time2% ( echo %%d %%e ) ) ) echo. pause >nul [ Last edited by zhoung0 on 2007-1-11 at 04:32 AM ] |
|
| Floor14 ben1985 | Posted 2007-02-12 12:23 |
| 新手上路 Posts 1 Credits 2 | |
|
Anqing hello!
My requirement is similar to yours. I need to find out the files generated at 9 PM every day and 9 PM the previous day. I'm a complete beginner and don't know how to compile this batch processing program. Please help me take a look |
|
| Floor15 slore | Posted 2007-02-12 13:18 |
| 铂金会员 Posts 2,478 Credits 5,212 | |
|
@echo off
setlocal enabledelayedexpansion set /p time1=Enter start time (format HH:MM:SS): set /p time2=Enter end time (format HH:MM:SS): set StartTime=%date:~0,4%%date:~5,2%%date:~8,2%%time1:~0,2%%time1:~3,2%%time1:~6,2% set EndtTime=%date:~0,4%%date:~5,2%%date:~8,2%%time2:~0,2%%time2:~3,2%%time2:~6,2% wmic datafile where "InstallDate>'%StartTime%.000000+480' and drive='d:' and InstallDate<'%EndtTime%.000000+480'" get caption>Result.txt This seems to only check.dat files. How to change it to all? |
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |