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

Author Topic: going crazy!! is this possible??  (Read 8714 times)

0 Members and 1 Guest are viewing this topic.

rancrazy

    Topic Starter


    Rookie

    going crazy!! is this possible??
    « on: March 31, 2009, 12:24:33 PM »
    Hi
      Can any one let me know ,is there any possibility that I can I extract lines with latest date  and each file name into different files?
    for example I want lines 03/21/09 with FILE4 to one file
    and lines 03/21/09 with FILE3 to other file.
    03/20/09 10:31:52 UPLOAD C:\TEMP\UPLOAD\FILE1_19Mar2009.zip)
    03/20/09 10:31:54 DOWNLOAD FILE1_19Mar2009.zip to C:\TEMP\DOWNLOAD\FILE1_19Mar2009.zip
    03/20/09 10:31:52 UPLOAD C:\TEMP\UPLOAD\FILE2_19Mar2009.zip)
    03/20/09 10:31:54 DOWNLOAD FILE2_19Mar2009.zip to C:\TEMP\DOWNLOAD\FILE2_19Mar2009.zip
    03/21/09 11:20:52 UPLOAD C:\TEMP\UPLOAD\FILE3_20Mar2009.zip)
    03/21/09 11:21:54 DOWNLOAD FILE3_20Mar2009.zip to C:\TEMP\DOWNLOAD\FILE3_20Mar2009.zip
    03/21/09 12:31:52 UPLOAD C:\TEMP\UPLOAD\FILE4_20Mar2009.zip)
    03/21/09 12:31:54 DOWNLOAD FILE4_20Mar2009.zip to C:\TEMP\DOWNLOAD\FILE4_20Mar2009.zip

    Its very urgent and please help me!!!!!

    Dias de verano

    • Guest
    Re: going crazy!! is this possible??
    « Reply #1 on: March 31, 2009, 02:28:57 PM »
    1. test.txt

    Code: [Select]

    03/20/09 10:31:52 UPLOAD C:\TEMP\UPLOAD\FILE1_19Mar2009.zip)
    03/20/09 10:31:54 DOWNLOAD FILE1_19Mar2009.zip to C:\TEMP\DOWNLOAD\FILE1_19Mar2009.zip
    03/20/09 10:31:52 UPLOAD C:\TEMP\UPLOAD\FILE2_19Mar2009.zip)
    03/20/09 10:31:54 DOWNLOAD FILE2_19Mar2009.zip to C:\TEMP\DOWNLOAD\FILE2_19Mar2009.zip
    03/21/09 11:20:52 UPLOAD C:\TEMP\UPLOAD\FILE3_20Mar2009.zip)
    03/21/09 11:21:54 DOWNLOAD FILE3_20Mar2009.zip to C:\TEMP\DOWNLOAD\FILE3_20Mar2009.zip
    03/21/09 12:31:52 UPLOAD C:\TEMP\UPLOAD\FILE4_20Mar2009.zip)
    03/21/09 12:31:54 DOWNLOAD FILE4_20Mar2009.zip to C:\TEMP\DOWNLOAD\FILE4_20Mar2009.zip


    2. Batch file

    Code: [Select]

    @echo off
    setlocal enabledelayedexpansion
    set filename=test.txt
    REM pass 1 - determine latest date
    echo Examining file - determining latest date
    echo.
    set maxdatenum=0
    set lastdate=
    for /f "delims=" %%L in ( ' type "%filename%" ' ) do (
    set thisline=%%L
    set datestamp=!thisline:~0,8!
    set dateD=!datestamp:~0,2!
    set dateM=!datestamp:~3,2!
    set dateY=20!datestamp:~6,2!
    set datenum=!dateY!!dateM!!dateD!
    if !datenum! GTR !maxdatenum! (
    set maxdatenum=!datenum!
    set lastdate=!datestamp!
    echo found date:   !datestamp!
    )
    )
    echo Latest date : %lastdate%
    echo.
    REM pass 2 - extract lines from latest date containg FILE3_
    echo Lines starting with date %lastdate% containing FILE3_ :
    echo.
    for /f "delims=" %%L in ( ' type "%filename%" ^| find "%lastdate%" ^| find "FILE3_" ' ) do echo %%L
    echo.
    REM pass 3 - extract lines from latest date containg FILE4_
    echo Lines starting with date %lastdate% containing FILE4_ :
    echo.
    for /f "delims=" %%L in ( ' type "%filename%" ^| find "%lastdate%" ^| find "FILE4_" ' ) do echo %%L
    echo.


    Code: [Select]

    Examining file - determining latest date

    found date:   03/20/09
    found date:   03/21/09
    Latest date : 03/21/09

    Lines starting with date 03/21/09 containing FILE3_ :

    03/21/09 11:20:52 UPLOAD C:\TEMP\UPLOAD\FILE3_20Mar2009.zip)
    03/21/09 11:21:54 DOWNLOAD FILE3_20Mar2009.zip to C:\TEMP\DOWNLOAD\FILE3_20Mar2009.zip

    Lines starting with date 03/21/09 containing FILE4_ :

    03/21/09 12:31:52 UPLOAD C:\TEMP\UPLOAD\FILE4_20Mar2009.zip)
    03/21/09 12:31:54 DOWNLOAD FILE4_20Mar2009.zip to C:\TEMP\DOWNLOAD\FILE4_20Mar2009.zip


    rancrazy

      Topic Starter


      Rookie

      Re: going crazy!! is this possible??
      « Reply #2 on: March 31, 2009, 05:01:54 PM »
      Thanks a lot.It worked wonderfully.Is there any possibility that we can apply this to a case where
      FILE3_ and FILE4_  are replaced with P2210223_ and P3104234_  etc But instead of manually finding the string for FILE3_ and FILE4_ this batch script should automate to seperate such files upload and download lines with latest date.I want seperate extractions for P2210223_ UPLOAD and DOWNLOAD lines from test.txt and same for the other P3104234_.
       
       

      Dias de verano

      • Guest
      Re: going crazy!! is this possible??
      « Reply #3 on: April 01, 2009, 12:18:15 AM »
      Thanks a lot.It worked wonderfully.Is there any possibility that we can apply this to a case where
      FILE3_ and FILE4_  are replaced with P2210223_ and P3104234_  etc But instead of manually finding the string for FILE3_ and FILE4_ this batch script should automate to seperate such files upload and download lines with latest date.I want seperate extractions for P2210223_ UPLOAD and DOWNLOAD lines from test.txt and same for the other P3104234_.
       
       


      To clarify:

      You want 4 extractions:

      Latest date P2210223_ UPLOAD
      Latest date P2210223_ DOWNLOAD
      Latest date P3104234_ UPLOAD
      Latest date P3104234_ DOWNLOAD

      Is that correct?

      It would help if you supply a specimen file like you did before.



      rancrazy

        Topic Starter


        Rookie

        Re: going crazy!! is this possible??
        « Reply #4 on: April 01, 2009, 08:09:36 AM »
        This is a sample file extactly looks like my data
        03/24/09 13:54:23  UPLOAD (C:\TEMP\P2207246  DATA TRANSFER\119073327 message.txt))

        03/31/09 14:00:28  UPLOAD (C:\TEMP\P2207247 DATA TRANSFER\P2207247_TRF_31Mar2009.zip)
        03/31/09 14:00:28  DOWNLOAD P2207247_TRF_31Mar2009.zip to C:\TEMP\P2207247_TRF_31Mar2009.zip

        03/31/09 14:00:30  UPLOAD (C:\TEMP\P2207247  DATA TRANSFER\119073399 message.txt)

        03/31/09 07:03:02  UPLOAD (C:\TEMP\P33108245_TRF_31Mar2009\P33108205_TRF_31Mar2009.zip)
        03/31/09 07:03:02  DOWNLOAD P33108245_TRF_31Mar2009.zip to C:\TEMP\P33108205_TRF_31Mar2009.zip

        I need UPLOAD and DOWNLOAD lines for P2207247 in seperate file and P33108245 in seperate file.My requirement is to automate this process.single UPLOAD lines can be ignored.I have seperated the data for clear image of my requirement.My Log file contains several other lines with different names starting with P31...etc I hope I did not mess up.

        Dias de verano

        • Guest
        Re: going crazy!! is this possible??
        « Reply #5 on: April 01, 2009, 09:46:26 AM »
        6 questions below:

        1. Two files therefore?

        P2207247 upload and download
        P33108245 upload and download


        2. Ignore single upload lines, only extract matching upload / download pairs like these below?
        3. Will they always be on consecutive lines like this?
        4. Do they always have identical date and time stamps?


        03/31/09 14:00:28  UPLOAD (C:\TEMP\P2207247 DATA TRANSFER\P2207247_TRF_31Mar2009.zip)
        03/31/09 14:00:28  DOWNLOAD P2207247_TRF_31Mar2009.zip to C:\TEMP\P2207247_TRF_31Mar2009.zip

        03/31/09 07:03:02  UPLOAD (C:\TEMP\P33108245_TRF_31Mar2009\P33108205_TRF_31Mar2009.zip)
        03/31/09 07:03:02  DOWNLOAD P33108245_TRF_31Mar2009.zip to C:\TEMP\P33108205_TRF_31Mar2009.zip


        Quote from: rancrazy
        My Log file contains several other lines with different names starting with P31...etc

        5. I hope all lines will start with a date. Hopefully the names starting P31... etc are in the places where P22... and P33... are in the example above?

        6. Such lines starting P31... etc to be ignored?

        rancrazy

          Topic Starter


          Rookie

          Re: going crazy!! is this possible??
          « Reply #6 on: April 01, 2009, 10:32:06 AM »
          First of all thank you so much for helping me.
          1. Two files therefore? YES for this example but there are more line starting with P31 or P22,P15 etc having UPLOAD and DOWNLOAD lines with latest date

          P2207247 upload and download
          P33108245 upload and download


          2. Ignore single upload lines, only extract matching upload / download pairs like these below? YES
          3. Will they always be on consecutive lines like this? YES
          4. Do they always have identical date and time stamps? almost same but some times one second diff may be there


          03/31/09 14:00:28  UPLOAD (C:\TEMP\P2207247 DATA TRANSFER\P2207247_TRF_31Mar2009.zip)
          03/31/09 14:00:28  DOWNLOAD P2207247_TRF_31Mar2009.zip to C:\TEMP\P2207247_TRF_31Mar2009.zip

          03/31/09 07:03:02  UPLOAD (C:\TEMP\P33108245_TRF_31Mar2009\P33108205_TRF_31Mar2009.zip)
          03/31/09 07:03:02  DOWNLOAD P33108245_TRF_31Mar2009.zip to C:\TEMP\P33108205_TRF_31Mar2009.zip


          5. I hope all lines will start with a date. Hopefully the names starting P31... etc are in the places where P22... and P33... are in the example above? Yes all the lines start with date.names with P31, P21,P15 etc

          6. Such lines starting P31... etc to be ignored? no only lines with single UPLOAD unlike pairing UPLOAD and DOWNLOAD.These single lines show that data was not DOWNLOADED.so not required.

          Dias de verano

          • Guest
          Re: going crazy!! is this possible??
          « Reply #7 on: April 01, 2009, 10:48:50 AM »
          Now I am more confused.

          Do you just want these 2 files?

          P2207247 upload and download
          P33108245 upload and download

          All other Pxx numbers ignored?

          Only upload/download pairs?


          rancrazy

            Topic Starter


            Rookie

            Re: going crazy!! is this possible??
            « Reply #8 on: April 01, 2009, 10:57:41 AM »
            I mean to say I have several additional line like below.I need a batch script to get UPLOAD/DOWNLOAD pairs of each one into seperate file.If any single line with UPLOAD is found can be ignored.
             
            03/31/09 14:00:28  UPLOAD (C:\TEMP\P2207247 DATA TRANSFER\P2207247_TRF_31Mar2009.zip)
            03/31/09 14:00:28  DOWNLOAD P2207247_TRF_31Mar2009.zip to C:\TEMP\P2207247_TRF_31Mar2009.zip

            03/31/09 07:03:02  UPLOAD (C:\TEMP\P33108245_TRF_31Mar2009\P33108205_TRF_31Mar2009.zip)
            03/31/09 07:03:02  DOWNLOAD P33108245_TRF_31Mar2009.zip to C:\TEMP\P33108205_TRF_31Mar2009.zip

            03/31/09 15:00:28  UPLOAD (C:\TEMP\P2107244 DATA TRANSFER\PP2107244_TRF_31Mar2009.zip)
            03/31/09 15:00:28  DOWNLOAD P2107244_TRF_31Mar2009.zip to C:\TEMP\PP2107244_TRF_31Mar2009.zip

            03/31/09 20:03:02  UPLOAD (C:\TEMP\P3106230_TRF_31Mar2009\P3106230_TRF_31Mar2009.zip)
            03/31/09 20:03:02  DOWNLOAD P3106230_TRF_31Mar2009.zip to C:\TEMP\P3106230_TRF_31Mar2009.zip

            03/31/09 14:00:30  UPLOAD (C:\TEMP\P2207247  DATA TRANSFER\119073399 message.txt)(This line can be ignored)


            Dias de verano

            • Guest
            Re: going crazy!! is this possible??
            « Reply #9 on: April 01, 2009, 11:08:56 AM »
            1. So ALL upload / download pairs?
            2. whatever the Pxxxxx number they share?
            3. and into separate files? One file for each pair? Like this (see below)?
            4. And how shall the files be named? (By the Pxxxxx number maybe?)
            5. Is UPLOAD always the first line of such a pair?
            6. Is the file format always Pxxxxxxx_TRF_date.zip ?
            7. Is each Pxxxxxxx number unique? (could it occur more than once?)

            file1
            Code: [Select]
            03/31/09 14:00:28  UPLOAD (C:\TEMP\P2207247 DATA TRANSFER\P2207247_TRF_31Mar2009.zip)
            03/31/09 14:00:28  DOWNLOAD P2207247_TRF_31Mar2009.zip to C:\TEMP\P2207247_TRF_31Mar2009.zip

            file2
            Code: [Select]
            03/31/09 07:03:02  UPLOAD (C:\TEMP\P33108245_TRF_31Mar2009\P33108205_TRF_31Mar2009.zip)
            03/31/09 07:03:02  DOWNLOAD P33108245_TRF_31Mar2009.zip to C:\TEMP\P33108205_TRF_31Mar2009.zip

            file3
            Code: [Select]
            03/31/09 15:00:28  UPLOAD (C:\TEMP\P2107244 DATA TRANSFER\PP2107244_TRF_31Mar2009.zip)
            03/31/09 15:00:28  DOWNLOAD P2107244_TRF_31Mar2009.zip to C:\TEMP\PP2107244_TRF_31Mar2009.zip

            file4 etc
            Code: [Select]
            03/31/09 20:03:02  UPLOAD (C:\TEMP\P3106230_TRF_31Mar2009\P3106230_TRF_31Mar2009.zip)
            03/31/09 20:03:02  DOWNLOAD P3106230_TRF_31Mar2009.zip to C:\TEMP\P3106230_TRF_31Mar2009.zip






            rancrazy

              Topic Starter


              Rookie

              Re: going crazy!! is this possible??
              « Reply #10 on: April 01, 2009, 11:21:27 AM »
              1. So ALL upload / download pairs? Yes
              2. whatever the Pxxxxx number they share? Yes
              3. and into separate files? One file for each pair? Like this (see below)? Yes one file for each pair
              4. And how shall the files be named? (By the Pxxxxx number maybe?) Pxxxxx_date
              5. Is UPLOAD always the first line of such a pair? Yes Upload is first line
              6. Is the file format always Pxxxxxxx_TRF_date.zip ? Yes
              7. Is each Pxxxxxxx number unique? (could it occur more than once?) No It can occur more than once some times

              Dias de verano

              • Guest
              Re: going crazy!! is this possible??
              « Reply #11 on: April 01, 2009, 11:44:35 AM »
              7. Is each Pxxxxxxx number unique? (could it occur more than once?) No It can occur more than once some times

              More than once on the same date?




              rancrazy

                Topic Starter


                Rookie

                Re: going crazy!! is this possible??
                « Reply #12 on: April 01, 2009, 11:49:04 AM »
                Yes it can be on same date but we have to extract most current time stamp from those two.

                Dias de verano

                • Guest
                Re: going crazy!! is this possible??
                « Reply #13 on: April 01, 2009, 12:12:28 PM »
                Yes it can be on same date but we have to extract most current time stamp from those two.

                The task keeps growing... Have you thought about employing a programmer? This is high grade work.


                rancrazy

                  Topic Starter


                  Rookie

                  Re: going crazy!! is this possible??
                  « Reply #14 on: April 01, 2009, 12:19:52 PM »
                  well this is not a growing task but my actual requirement and as I am new to batch scripting it is looking like impossible task for me. ???Even if you can help me one occurence (most current stamp not required) I will mange some how.please help me out