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

Author Topic: Created .bat file that appends to another file...EDI_Results.txt  (Read 4294 times)

0 Members and 1 Guest are viewing this topic.

dkennelly

    Topic Starter


    Rookie

    I am appending to a file called EDI_Results.txt.

    I am using "dir >> C:\FTPData\EDI\EDI_Results.txt" to append the current directory to the file EDI_Results.txt.  The file ends up looking like this.....

     =============== BRIDIUM EXPORT ==================
     Volume in drive C is OS
     Volume Serial Number is 709D-2487

     Directory of C:\FTPData\EDI\Export

    05/14/2010  08:58 AM    <DIR>          .
    05/14/2010  08:58 AM    <DIR>          ..
    05/15/2009  04:59 PM    <DIR>          2003
    05/15/2009  04:59 PM    <DIR>          2004
    05/15/2009  04:59 PM    <DIR>          2005
    05/15/2009  04:59 PM    <DIR>          2006
    05/15/2009  04:59 PM    <DIR>          2007
    05/15/2009  04:59 PM    <DIR>          2008
    05/15/2009  04:58 PM    <DIR>          2009
    12/23/2009  11:02 AM    <DIR>          2010
    05/13/2010  06:52 PM            76,963 bridium.txt
    05/15/2009  04:58 PM    <DIR>          MMI
    05/13/2010  09:00 PM           708,721 MMIClaimExtraction
    05/13/2010  04:44 PM    <DIR>          PROCESSES
    07/30/2009  08:25 AM    <DIR>          StateIN
                   2 File(s)        785,684 bytes
                  13 Dir(s)  51,192,061,952 bytes free
     ================= BRIDIUM IMPORT =====================
     ================= BRIDIUM IMPORT =====================
     Volume in drive C is OS
     Volume Serial Number is 709D-2487

     Directory of C:\FTPData\EDI\Import

    05/14/2010  08:05 AM    <DIR>          .
    05/14/2010  08:05 AM    <DIR>          ..
    05/15/2009  04:58 PM    <DIR>          2004
    05/15/2009  04:58 PM    <DIR>          2005
    05/15/2009  04:58 PM    <DIR>          2007
    05/15/2009  04:58 PM    <DIR>          2008
    05/15/2009  04:58 PM    <DIR>          2009
    12/23/2009  11:04 AM    <DIR>          2010
    05/14/2010  08:05 AM             6,859 Acks20100513200122.txt
    05/14/2010  08:05 AM            19,486 Acks20100513210106.txt
    05/14/2010  08:05 AM            13,753 Acks20100513220230.txt
    05/15/2009  04:58 PM    <DIR>          Archive Test
    05/15/2009  04:58 PM    <DIR>          iVOS
    05/14/2010  08:05 AM    <DIR>          LastWeeksFiles
    05/15/2009  04:58 PM    <DIR>          PROCESSES
    05/15/2009  04:58 PM    <DIR>          save
    05/15/2009  04:58 PM    <DIR>          State
    05/15/2009  04:58 PM    <DIR>          Success
    05/15/2009  04:58 PM    <DIR>          Test
                   3 File(s)         40,098 bytes
                  16 Dir(s)  51,192,061,952 bytes free

    All I am really looking for is the files, date and size included.  I want it to look cleaner.  Is there any way to just append the files in the directory with the date stamp and file size??

    dkennelly

      Topic Starter


      Rookie

      Re: Created .bat file that appends to another file...EDI_Results.txt
      « Reply #1 on: May 14, 2010, 09:25:27 AM »
      My .bat file looks like this...

      ftp -s:Bridiumexport.txt
      C:
      cd\
      cd FTPData\EDI\Export
      echo >> C:\FTPData\EDI\EDI_Results.txt =============== BRIDIUM EXPORT ==================
      dir >> C:\FTPData\EDI\EDI_Results.txt
      dir

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: Created .bat file that appends to another file...EDI_Results.txt
      « Reply #2 on: May 14, 2010, 10:16:10 AM »
      This may work:

      Code: [Select]
      ftp -s:Bridiumexport.txt
      C:
      cd\
      cd FTPData\EDI\Export
      echo >> C:\FTPData\EDI\EDI_Results.txt =============== BRIDIUM EXPORT ==================
      for /f "tokens=* delims=" %%i in ('dir /s /b') do (
        echo %%~ti %%~zi %%~ni%%~xi  >> C:\FTPData\EDI\EDI_Results.txt
      )
      type C:\FTPData\EDI\EDI_Results.txt

      Good luck. 8)
      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      dkennelly

        Topic Starter


        Rookie

        Re: Created .bat file that appends to another file...EDI_Results.txt
        « Reply #3 on: May 14, 2010, 12:47:18 PM »
        Worked like a champ! 

        Thanks for your help!

        dkennelly

          Topic Starter


          Rookie

          Re: Created .bat file that appends to another file...EDI_Results.txt
          « Reply #4 on: May 17, 2010, 10:20:24 AM »
          I spoke to soon.  It worked in my test environment, but when I applied it to production, It brought in all directories and files of the parent folder...please help...

           ================= BRIDIUM IMPORT =====================
          05/15/2009 04:58 PM   0   2004 
          05/15/2009 04:58 PM   0   2005 
          05/15/2009 04:58 PM   0   2007 
          05/15/2009 04:58 PM   0   2008 
          05/15/2009 04:58 PM   0   2009 
          12/23/2009 11:04 AM   0   2010 
          05/15/2009 04:58 PM   0   Archive Test 
          05/15/2009 04:58 PM   0   iVOS 
          05/14/2010 08:05 AM   0   LastWeeksFiles 
          05/15/2009 04:58 PM   0   PROCESSES 
          05/15/2009 04:58 PM   0   save 
          05/15/2009 04:58 PM   0   State 
          05/15/2009 04:58 PM   0   Success 
          05/15/2009 04:58 PM   0   Test 
          05/15/2009 04:58 PM   0   20040225a 
          05/15/2009 04:58 PM   0   20040308a 
          05/15/2009 04:58 PM   0   20040330a 
          05/15/2009 04:58 PM   0   20040429a 
          05/15/2009 04:58 PM   0   20040607a 
          05/15/2009 04:58 PM   0   20040610a 
          05/15/2009 04:58 PM   0   20040611a 
          05/15/2009 04:58 PM   0   20040616a...

          ------------------------------------------------------------------------------

          My bat file looks like this...

          ftp -s:Bridiumimport.txt
          C:
          cd\
          cd FTPData\EDI\Import
          echo > C:\FTPData\EDI\EDI_Results.txt ================= BRIDIUM IMPORT =====================
          for /f "tokens=* delims=" %%i in ('dir /s /b') do (echo %%~ti   %%~zi   %%~ni%%~xi  >> C:\FTPData\EDI\EDI_Results.txt)
          type C:\FTPData\EDI\EDI_Results.txt

          Sidewinder



            Guru

            Thanked: 139
          • Experience: Familiar
          • OS: Windows 10
          Re: Created .bat file that appends to another file...EDI_Results.txt
          « Reply #5 on: May 17, 2010, 11:06:18 AM »
          Quick fix. Remove the recurse switch (/s).

          Code: [Select]
          ftp -s:Bridiumimport.txt
          C:
          cd\
          cd FTPData\EDI\Import
          echo > C:\FTPData\EDI\EDI_Results.txt ================= BRIDIUM IMPORT =====================
          for /f "tokens=* delims=" %%i in ('dir /b') do (echo %%~ti   %%~zi   %%~ni%%~xi  >> C:\FTPData\EDI\EDI_Results.txt)
          type C:\FTPData\EDI\EDI_Results.txt

          Hope this helps.  8)
          The true sign of intelligence is not knowledge but imagination.

          -- Albert Einstein

          dkennelly

            Topic Starter


            Rookie

            Re: Created .bat file that appends to another file...EDI_Results.txt
            « Reply #6 on: May 17, 2010, 11:22:26 AM »
            That took care of the child directory issue, but it is still pulling in folders from the parent directory.  Anyway to just pull in files and not include the folders?

            Sidewinder



              Guru

              Thanked: 139
            • Experience: Familiar
            • OS: Windows 10
            Re: Created .bat file that appends to another file...EDI_Results.txt
            « Reply #7 on: May 17, 2010, 11:47:26 AM »
            Code: [Select]
            ftp -s:Bridiumimport.txt
            C:
            cd\
            cd FTPData\EDI\Import
            echo > C:\FTPData\EDI\EDI_Results.txt ================= BRIDIUM IMPORT =====================
            for /f "tokens=* delims=" %%i in ('dir /a-d /b') do (echo %%~ti   %%~zi   %%~ni%%~xi  >> C:\FTPData\EDI\EDI_Results.txt)
            type C:\FTPData\EDI\EDI_Results.txt

            Run dir /? from command prompt for details on the dir command
            Run for /? from command prompt for details on the for command

            The for help (at the very end) will also have details how to extract the full path of the file name in case you want the same format as my original post.

             8)
            The true sign of intelligence is not knowledge but imagination.

            -- Albert Einstein

            dkennelly

              Topic Starter


              Rookie

              Re: Created .bat file that appends to another file...EDI_Results.txt
              « Reply #8 on: May 17, 2010, 12:15:44 PM »
              Thank you very much for your help.

              dkennelly

                Topic Starter


                Rookie

                Re: Created .bat file that appends to another file...EDI_Results.txt
                « Reply #9 on: May 17, 2010, 02:05:45 PM »
                Oh yeah.......

                This did it......

                for /f "tokens=* delims=" %%i in ('dir /a:a /o:s /b') do (echo %%~ti   %%~zi%%~ni%%~xi  >> EDI_Results.txt)

                dkennelly

                  Topic Starter


                  Rookie

                  Re: Created .bat file that appends to another file...EDI_Results.txt
                  « Reply #10 on: May 18, 2010, 11:09:24 AM »
                  This works also....

                  for /f "tokens=* delims=" %%i in ('dir /a:-d /o:s /b') do (echo %%~ti   %%~zi%%~ni%%~xi  >> EDI_Results.txt)