Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: search for files with special (names size and modified date)  (Read 5332 times)

0 Members and 1 Guest are viewing this topic.

mioo_sara

    Topic Starter


    Intermediate

    Re: search for files with special (names size and modified date)
    « Reply #15 on: June 09, 2009, 07:21:54 AM »
    wow ! at last  i done it. 8) 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 :)

    devcom



      Apprentice

      Thanked: 37
      Re: search for files with special (names size and modified date)
      « Reply #16 on: June 09, 2009, 08:10:25 AM »
      use %%~tA
      Download: Choice.exe

      mioo_sara

        Topic Starter


        Intermediate

        Re: search for files with special (names size and modified date)
        « Reply #17 on: June 09, 2009, 09:53:13 AM »
        sorry  dear devcom :)
        i forgot to  tell  you  i tried your codes yesterday  but maybe it's me that has problem  :||x 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?

        devcom



          Apprentice

          Thanked: 37
          Re: search for files with special (names size and modified date)
          « Reply #18 on: June 09, 2009, 10:28:25 AM »
          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.txt
          Download: Choice.exe

          mioo_sara

            Topic Starter


            Intermediate

            Re: search for files with special (names size and modified date)
            « Reply #19 on: June 09, 2009, 12:32:22 PM »
            wrong !! :(
            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? :P
            by  the way   in CMD report i see 02/03/2008 but java2.exe properties shows 2008/03/02 which  one is correct?