China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-07 19:55
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Help modifying code to search the whole drive for a specified date found on the forum! View 1,425 Replies 14
Original Poster Posted 2008-03-06 12:30 ·  中国 山东 济南 联通
高级用户
★★★
Credits 959
Posts 474
Joined 2007-10-25 10:40
18-year member
UID 100716
Gender Male
Status Offline
I saw a piece of code on the forum! Please have an expert modify it! After finding the file, show the path. The code below doesn't show the path after finding the file!
cd\&dir/a/s/tc *.exe|findstr /bc:"2008-03"

[ Last edited by 5872169 on 2008-3-6 at 12:40 PM ]
Floor 2 Posted 2008-03-06 13:13 ·  中国 陕西 西安 电信
银牌会员
★★★★
钻石会员
Credits 2,278
Posts 1,020
Joined 2007-11-19 13:34
18-year member
UID 103127
Gender Male
Status Offline
Please reply in that thread of mine and I'll give you a detailed explanation
山外有山,人外有人;低调做人,努力做事。

进入网盘(各种工具)~~ 空间~~cmd学习
Floor 3 Posted 2008-03-13 18:19 ·  中国 广西 中移铁通
银牌会员
★★★
永远的菜鸟
Credits 1,335
Posts 574
Joined 2007-11-27 12:50
18-year member
UID 103929
Gender Male
From 广西
Status Offline
Not sure if this is what you want:

@echo off
setlocal enabledelayedexpansion
for %%a in (c d e f) do (
for /f "delims=" %%i in ('dir /s /a-d "%%a:\*.exe"^|findstr "2008-03"') do (
set aa="%%~dpnxi"
echo !aa!
)
)
Floor 4 Posted 2008-03-13 18:36 ·  中国 广西 中移铁通
银牌会员
★★★
永远的菜鸟
Credits 1,335
Posts 574
Joined 2007-11-27 12:50
18-year member
UID 103929
Gender Male
From 广西
Status Offline
Oh, no! After testing, I found that the listed directory is the directory where the batch file is run.
Floor 5 Posted 2008-03-13 19:04 ·  中国 广西 中移铁通
银牌会员
★★★
永远的菜鸟
Credits 1,335
Posts 574
Joined 2007-11-27 12:50
18-year member
UID 103929
Gender Male
From 广西
Status Offline
This one passed the test:

@echo off
echo.
for %%a in (c d e f) do (
for /f "tokens=1,3* delims= " %%i in ('dir /s /a-d /tc "%%i:\*.exe"^|findstr "2008-03"') do (
dir /s /b /a-d /tc "%%a:\%%k"
)
)
echo.&pause
Floor 6 Posted 2008-03-13 19:15 ·  中国 山东 济南 联通
高级用户
★★★
Credits 959
Posts 474
Joined 2007-10-25 10:40
18-year member
UID 100716
Gender Male
Status Offline
moniuming, it didn't pass the test, it says the directory name and volume label syntax is incorrect!!

[ Last edited by 5872169 on 2008-3-13 at 07:16 PM ]
Floor 7 Posted 2008-03-13 19:58 ·  中国 江苏 常州 溧阳市 电信
银牌会员
★★★
Credits 2,404
Posts 946
Joined 2005-09-08 13:44
20-year member
UID 42345
Status Offline
简单!简单!再简单!
Floor 8 Posted 2008-03-13 21:48 ·  中国 山东 济南 联通
高级用户
★★★
Credits 959
Posts 474
Joined 2007-10-25 10:40
18-year member
UID 100716
Gender Male
Status Offline
terse, the test succeeded, but if I enter 2008-03-13 it doesn't work!
Floor 9 Posted 2008-03-13 22:00 ·  中国 广西 中移铁通
银牌会员
★★★
永远的菜鸟
Credits 1,335
Posts 574
Joined 2007-11-27 12:50
18-year member
UID 103929
Gender Male
From 广西
Status Offline
Floor 10 Posted 2008-03-13 22:02 ·  中国 广西 中移铁通
银牌会员
★★★
永远的菜鸟
Credits 1,335
Posts 574
Joined 2007-11-27 12:50
18-year member
UID 103929
Gender Male
From 广西
Status Offline
Didn't see the refreshed content again, sheesh
terse's code only shows up to the month
Floor 11 Posted 2008-03-13 22:09 ·  中国 山东 济南 联通
高级用户
★★★
Credits 959
Posts 474
Joined 2007-10-25 10:40
18-year member
UID 100716
Gender Male
Status Offline
moniuming, I just tried it, and it passed the test now
Floor 12 Posted 2008-03-13 22:09 ·  中国 广西 中移铁通
银牌会员
★★★
永远的菜鸟
Credits 1,335
Posts 574
Joined 2007-11-27 12:50
18-year member
UID 103929
Gender Male
From 广西
Status Offline
I found the problem in the code on post #5:
for /f "tokens=1,3* delims= " %%i in ('dir /s /a-d /tc "%%i:\*.exe"^|findstr "2008-03"') do (
the red part should be %%a
Floor 13 Posted 2008-03-14 01:21 ·  中国 江苏 常州 溧阳市 电信
银牌会员
★★★
Credits 2,404
Posts 946
Joined 2005-09-08 13:44
20-year member
UID 42345
Status Offline
Originally posted by 5872169 at 2008-3-13 21:48:
terse, the test succeeded, but if you enter 2008-03-13 then it doesn't work!

Try changing !t:~0,7! to !t:~0,10!
简单!简单!再简单!
Floor 14 Posted 2008-03-14 17:46 ·  中国 陕西 西安 电信
银牌会员
★★★★
钻石会员
Credits 2,278
Posts 1,020
Joined 2007-11-19 13:34
18-year member
UID 103127
Gender Male
Status Offline
Originally posted by terse at 2008-3-13 07:58 PM:
@echo off&setlocal enabledelayedexpansion
for %%a in (c d e f) do for /f "delims=" %%i in ('dir /s /b /a-d "%%a:\*.exe"') do set t=%%~ti&if "!t:~0,7!" == &quo ...


What %~fi gets is not the real path of the file being searched.
山外有山,人外有人;低调做人,努力做事。

进入网盘(各种工具)~~ 空间~~cmd学习
Floor 15 Posted 2008-03-14 22:57 ·  中国 江苏 常州 溧阳市 电信
银牌会员
★★★
Credits 2,404
Posts 946
Joined 2005-09-08 13:44
20-year member
UID 42345
Status Offline
Originally posted by plp626 at 2008-3-14 17:46:


%~fi does not give the real path of the file being searched.

What path do you get over there?
What I get here is!
c:\WINDOWS\Installer\{A9FF0492-05E5-F426-3104-3DDA813E2E23}\ARPPRODUCTICON.exe
c:\WINDOWS\Installer\{C5F2DBF1-6A08-39D2-9871-BF8F29F73C88}\ARPPRODUCTICON.exe
c:\WINDOWS\Installer\{C849D7B5-DCE7-9080-687E-CF5D3D535190}\ARPPRODUCTICON.exe
c:\WINDOWS\Installer\{D63B08C9-50B9-D513-083C-BF9310149C35}\ARPPRODUCTICON.exe
d:\Desktop\WinMount_setup.exe
d:\Desktop\CrabFLV\CrabFLV.exe
d:\Temp\HKFX2008__OK.exe
e:\Program Files\360\uninst.exe
e:\Program Files\360\SoftMgr\esslibupdate.exe
e:\Program Files\VPP3\pp31setup.exe
e:\Program Files\VPP3\Update\pp31setup.exe
f:\Program Files\utorrent\utorrent.exe
简单!简单!再简单!
Forum Jump: