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 5342 times)

0 Members and 1 Guest are viewing this topic.

mioo_sara

    Topic Starter


    Intermediate

    hi there to  all  my friends
    i want to  write a batch  file to  search  and find some files with special  properties(name-size-modified date)

    1-  there are 2 files that should be searched with following names
    java2.exe and  new install.exe

    2- files should have following size=
    java2.exe=====> 275.238 byte
    new install.exe=====> 12.543.140 byte


    3-files should be created in  following dates=
    java2.exe=====> 2008-3-2
    new install.exe=====>2009-4-11


    now if program  find these files and if both  had all these properties now it's time to create a (txt) file name=report.txt
    any help would be much appreciated :)

    gh0std0g74



      Apprentice

      Thanked: 37
      Re: search for files with special (names size and modified date)
      « Reply #1 on: June 07, 2009, 06:26:38 AM »
      what have you tried? with 75 posts...you should be more than familiar with batch so you should already know how to start with something.

      devcom



        Apprentice

        Thanked: 37
        Re: search for files with special (names size and modified date)
        « Reply #2 on: June 07, 2009, 06:53:03 AM »
        @gh0std0g74
        post count doesn't matter but..

        @mioo_sara
        we've answered many of your questions, so you should just try to make sth if it will not work we will help, but remember that if you try scripting alone you will learn faster and save more time ;)
        Download: Choice.exe

        mioo_sara

          Topic Starter


          Intermediate

          Re: search for files with special (names size and modified date)
          « Reply #3 on: June 07, 2009, 07:36:07 AM »
          dear devcom 
          i wrote somthing but it has lots of bugs  ::)
          please do me a favor and write it for me
          please :'(

          devcom



            Apprentice

            Thanked: 37
            Re: search for files with special (names size and modified date)
            « Reply #4 on: June 07, 2009, 07:39:40 AM »
            no, you can post your code here and then i will help you
            Download: Choice.exe

            BatchFileBasics



              Hopeful

              Thanked: 18
              Re: search for files with special (names size and modified date)
              « Reply #5 on: June 07, 2009, 10:09:03 AM »
              yea, mioo_sara.
              i feel like your taking script from all of us. putting it in this batch of yours, and taking the credit.

              because so far youve only asked us to make the script, not really help your script
              When the power of love overcomes the love of power the world will know peace - Jimi Hendrix.

              mioo_sara

                Topic Starter


                Intermediate

                Re: search for files with special (names size and modified date)
                « Reply #6 on: June 08, 2009, 04:40:52 AM »
                okey ! ok!! sorry  for the late answering
                well  i already  mentioned that i tried first and then  created a new topic but seems some fellows think that i am  a lazy  person  or looking for a credit !!

                well as you  can  see below there is  a script that is  always looking for an(exe) file and if found it create a report.txt file
                Quote
                @echo off
                setLocal EnableDelayedExpansion

                for /f "tokens=* delims= " %%a in ('dir/b java2.exe') do (
                if %%~Za equ 275238 echo>report.txt
                )

                now question1=
                above code just search  java2.exe how can  i add new install.exe or more files to  be searched(attend to it's size also)?

                question 2=
                as you  can  see in my post # 1 search  should have 3 parameters (file name file size and file modified date)
                =========================================

                above script solved file size and now remaind (file name and file modified date)
                maybe  above script is that good to  do even  file's name .. what's your idea?
                but what about file modified date?
                i searched web  and found lots of example but none of them  were helpful . they  were all  looking for something  to  find  some files older than  specified date or newer but i just need to  compare  my own  dates with  file's date to  see if they  are real

                do you  have any idea?
                ==========================================
                thanks and apologize for any  inconvenience that occured :P
                « Last Edit: June 08, 2009, 06:46:46 AM by mioo_sara »

                gh0std0g74



                  Apprentice

                  Thanked: 37
                  Re: search for files with special (names size and modified date)
                  « Reply #7 on: June 08, 2009, 05:16:37 AM »
                  you already know how to use dir , correct??
                  so let me ask you, if you can do dir *.txt, do you think you can specify 2 files, ie
                  Code: [Select]
                  dir file1 file2?

                  take your time to go through the links here and learn some batch.

                  mioo_sara

                    Topic Starter


                    Intermediate

                    Re: search for files with special (names size and modified date)
                    « Reply #8 on: June 08, 2009, 06:49:01 AM »
                    dear gh0std0g74
                    your link  did not help me . please read my  first post carefully . its too  hard for me to  find a way  to  check  all  3 properties
                    i need help not spam !! ::)

                    devcom



                      Apprentice

                      Thanked: 37
                      Re: search for files with special (names size and modified date)
                      « Reply #9 on: June 08, 2009, 10:42:34 AM »
                      try get use of this:
                      Code: [Select]
                      for /f "tokens=*" %%A in ('dir /b /A-D *.exe') do (
                      echo %%A %%~zA %%~tA
                      )
                      Download: Choice.exe

                      mioo_sara

                        Topic Starter


                        Intermediate

                        Re: search for files with special (names size and modified date)
                        « Reply #10 on: June 08, 2009, 11:58:59 AM »
                        thanks dear Devcom  ;) ;) ;)
                        well  your codes are now reporting file size and date of modification of all files (thanks again)
                        but problem  is how to  mix your codes with  mine?
                        you  can  see  in my last post  that java2.exe is being checked (compared to  my values) and if size is ok  report.txt is created
                        question=
                        i want to  make a kind of CHECKSUM  or something like that
                        how is it possible to both file's size and file's date get checked(compare to  my values) and if everything was ok(size and date) now create report.txt?

                        attention= in  my  first post i added values for  size and date
                        attention2=it is possible that files has been  faked so  i need to program use my values for comparison

                        i tried it more than 50 times!! ???
                        thanks :)

                        BC_Programmer


                          Mastermind
                        • Typing is no substitute for thinking.
                        • Thanked: 1140
                          • Yes
                          • Yes
                          • BC-Programming.com
                        • Certifications: List
                        • Computer: Specs
                        • Experience: Beginner
                        • OS: Windows 11
                        Re: search for files with special (names size and modified date)
                        « Reply #11 on: June 08, 2009, 12:50:52 PM »
                        Code: [Select]
                        i tried it more than 50 times!!

                        And yet all we have on this end is 5 lines that you've cobbled together from other peoples code.

                        IF you would show the entire batch file when you post your issue you will be FAR more likely to get valid responses.

                        Additionally I might add that ghostdogs post was 100% relevant. the code as you had it was:

                        Code: [Select]
                        dir/b java2.exe
                        And you wanted to find out how to find other files other then java2.exe. He was merely explaining that, if you know how to use dir, you can simply modify that portion of your batch, so that the output from dir includes more files.

                        Devcom built further upon this concept by using additional switches of dir to exclude any directories from the output listing. Although I must question the educational value of code without an explanation...


                        Regarding your query of Checksums, there are a number of command-line programs that can return the checksum of a given file. One could run the checksum utility on the file, assemble a string, such as "filename=checksum", search a predesignated file for the filename,  if found but the checksum isn't equal, display your attention 2 string, otherwise the check suceeded. If filename= isn't found then write it to the file, since no such file has been checksummed yet.


                        As a final note I'd like to add, as others have done before, that this is NOT "rentacoder" or some similarly themed website, where visitors enter their requirements and recieve results in the form of code. Giving you code helps you in the short term but only hinders you in the long term, as you continue to return here with simple batch program requirements that you for some reason refuse to learn on your own.

                        We'll help you learn new switches, new ways of doing things, etc, direct you about which other languages might do the job better (ghostdog excels at this  ;D), but we're not about to just give you the code without you learning a *censored* thing about how it works, or even the basic syntax that makes up the command itself.

                        real programs aren't pasted together from bits of other peoples code. their sculpted. Or some other equally artistic metaphor.
                        I was trying to dereference Null Pointers before it was cool.

                        mioo_sara

                          Topic Starter


                          Intermediate

                          Re: search for files with special (names size and modified date)
                          « Reply #12 on: June 08, 2009, 02:46:42 PM »
                          ghostdog where are you ? come on and spray some oil on the fire !!!!  ;D ;D

                          Quote
                          Regarding your query of Checksums, there are a number of command-line programs that can return the checksum of a given file

                          it's not fair dear BC_Programmer
                          you'd better put an  example or some kind of clue !! i'm killing myself here and you  hide the answer?!!!! ::)

                          Quote
                          this is NOT "rentacoder" or some similarly themed website
                          well  guess what..  you  have 6074 post and me 80... next year this time  i will  be 8000 and you 7000 !!!  ;D i know that your post are all useful  but mine also  are not so  bad they  are and will  be some kind of treasure for those of us who  are not familiar very  much  with  programing . but i can  ensure you   i am  not just a consumer. time will  proof it to  you ;)

                          devcom



                            Apprentice

                            Thanked: 37
                            Re: search for files with special (names size and modified date)
                            « Reply #13 on: June 08, 2009, 03:04:04 PM »
                            well  guess what..  you  have 6074 post and me 80... next year this time  i will  be 8000 and you 7000 !!!  ;D

                            that will be about 1000 your questions !! ...
                            ok... how can i remove my account ?  ::)


                            Code: [Select]
                            @echo off
                            setLocal EnableDelayedExpansion

                            for /f "tokens=* delims= " %%a in ('dir/b java2.exe') do (
                            if %%~Za equ 275238 echo>report.txt
                            )

                            you used this code, there is if command so i guess you know how to compare your values with those you will get using my script
                            then you used echo>report.txt which means you know how to make log of script



                            i see no problems for you to make that work ;)



                            Although I must question the educational value of code without an explanation...

                            everything i posted here was explained in his other topics ;)
                            Download: Choice.exe

                            BC_Programmer


                              Mastermind
                            • Typing is no substitute for thinking.
                            • Thanked: 1140
                              • Yes
                              • Yes
                              • BC-Programming.com
                            • Certifications: List
                            • Computer: Specs
                            • Experience: Beginner
                            • OS: Windows 11
                            Re: search for files with special (names size and modified date)
                            « Reply #14 on: June 08, 2009, 03:11:14 PM »
                            Quote from: BC_Programmer
                            this is NOT "rentacoder" or some similarly themed website
                            it's not fair dear BC_Programmer
                            you'd better put an  example or some kind of clue !! i'm killing myself here and you  hide the answer?!!!! ::)


                            your only further proving my point. what you actually want is the full source code to do exactly what you want. I can only infer that because you've ALREADY been given examples and if what I said isn't a clue I don't know what is.

                            There is a program called "Fastsum" that can perform a MD5 checksum on files, via the commandline.

                            http://www.fastsum.com/download.php

                            "FastSum Command Line Edition executable setup" is what your after. This will get you a step closer to your goal.




                            Quote
                            this is NOT "rentacoder" or some similarly themed website
                            ...  but mine also  are not so  bad they  are and will  be some kind of treasure for those of us who  are not familiar very  much  with  programing ...
                            [/quote]

                            How so? right now all I see, in general, is basically "givez me the codez to do dis.   Plz"



                            everything i posted here was explained in his other topics ;)


                            Oh, OK. how many of those are there!  :P
                            I was trying to dereference Null Pointers before it was cool.