1.

Solve : search for files with special (names size and modified date)?

Answer»

wow ! at last i done it. i am now one step closer to the target

Quote

@echo off
setLocal EnableDelayedExpansion

for %%a in ("java2.exe") do set var1=%%~Za
for %%a in ("new install.exe") do set var2=%%~Za

if %var1% equ 275238 (
if %var2% equ 12543140 goto checktime

)

in above script you can now put lots of files and program will check their size (i put 2 files)
but now i need a pattern for compare and CHECKING files date with my values
any help or idea?
thanks use %%~tAsorry dear devcom
i forgot to tell you i tried your codes yesterday but maybe it's me that has problem not codes !!
i tried this

for /f "tokens=*" %%A in ('dir /b /A-D *.exe') do (
echo %%A %%~zA %%~tA
)
now i have this report in CMD window

Quote
java2.exe 275238 02/03/2008 11:50 AM

now what? how should i put these codes inside program?

i tried this (i removed file's size this time to find out what's the problem)

Quote
@echo off
setLocal EnableDelayedExpansion

for %%a in ("java2.exe") do set var1=%%~tA

if %var1% equ 02/03/2008 11:50 AM goto next
if %var1% NEQ 02/03/2008 11:50 AM echo>error.txt
)

i added red line to see which line has picked by program and always red line is selected !!
what's the correct pattern for putting file's date?

i even tried all below codes
Quote
02/03/2008 11:50
or
02/03/2008
or
2008/03/02

what's wrong?you need to add QOUTES on var and string you want to match becouse cmd thinks that 11:50 and AM are some commands so:

Code: [Select]if "%var1%" NEQ "02/03/2008 11:50 AM" echo>error.txt
that will work

i prefer only date so:
Code: [Select]for %%a in ("java2.exe") do set time1=%%~tA

REM GET DATE ONLY
for /f "tokens=1 delims= " %%a in ('echo %time1%') do set date1=%%a

if "%date1%" NEQ "02/03/2008" echo>error.txtwrong !!
hi dear devcom and THANK you very much for your cooperation
well your last codes did not work i don't know why ! i used following codes

Quote
for %%a in ("java2.exe") do set time1=%%~tA

REM GET DATE ONLY
for /f "tokens=1 delims= " %%a in ('echo %time1%') do set date1=%%a

if "%date1%" NEQ "02/03/2008" echo>error.txt

but i think there is something wrong . it always creates error.txt why?
i think NEQ means=not EQUAL . right? and equ= equal
so why it always create error.txt ? my values are not wrong. i even changed "02/03/2008" to anything example "02/04/2006"
and it still create error.txt so it will always searching for wrong values not correct values !! i replaced NEQ with equ and it did not worked. i mean this time did not create any txt so do you have any idea?
by the way in CMD report i see 02/03/2008 but java2.exe properties shows 2008/03/02 which one is correct?


Discussion

No Comment Found