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

Author Topic: Batch file to unzip multiple files...  (Read 8506 times)

0 Members and 1 Guest are viewing this topic.

NyteOwl

    Topic Starter


    Rookie

    Batch file to unzip multiple files...
    « on: June 27, 2008, 08:26:10 AM »
    I have a large number of zip files containing historical data that I need to uncompress. 

    The directory hierarchy is yearly parent folders with monthly sub-folders that each contain multiple zip files.

    What I need is a batch file that I can run from any yearly folder that will open each monthly folder, unzip the files, then move to the next monthly file until the entire year's worth of data has been uncompressed.  I've been given a custom executable to handle all uncompressing routine, so I just need something to open the January directory so I can call the executable, and then when finished, change to the February directory to repeat the process, and so on until all 12 monthly directories for that particular year have been processed.

    Sounds simple enough, but I thought maybe while a beginner like me was trying to figure it out someone with a lot more knowledge might have a quick solution for me.

    Thanks in advance...jack

    NyteOwl

      Topic Starter


      Rookie

      Re: Batch file to unzip multiple files...
      « Reply #1 on: June 27, 2008, 09:20:49 AM »
      Well, I figured out how to do this the hard way, but suggestions are still welcome...

      blastman



        Hopeful

        Re: Batch file to unzip multiple files...
        « Reply #2 on: June 27, 2008, 09:49:45 AM »
        I'm sure a loop would look nicier, but if I've understood you right, this should do....


        Code: [Select]
        @echo off

        set /p year="Enter year:  "

        cd c:\path\to\folder\conatining\years\%year%

        cd jan

        start /wait application_name.exe

        cd feb

        start /wait application_name.exe

        cd..

        cd mar

        start /wait application_name.exe

        cd..

        cd apr

        start /wait application_name.exe

        cd..

        cd may

        start /wait application_name.exe
        cd..

        cd jun

        start /wait application_name.exe

        cd..

        cd jul

        start /wait application_name.exe

        cd..

        cd aug

        start /wait application_name.exe

        cd..

        cd Sept

        start /wait application_name.exe

        cd..

        cd oct

        start /wait application_name.exe

        cd..

        cd nov

        start /wait application_name.exe

        cd..

        cd dec

        start /wait application_name.exe



        Blastman, you are the man. Thank You Very Much!!!!!!!!!



        NyteOwl

          Topic Starter


          Rookie

          Re: Batch file to unzip multiple files...
          « Reply #3 on: June 27, 2008, 10:27:07 AM »
          Thanks blastman, but that's real similar to what I ended up doing.

          I was hoping for a loop, but I suspect the processing will be complete by EOB today...

          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: Batch file to unzip multiple files...
          « Reply #4 on: June 27, 2008, 08:15:06 PM »
          instead of:
          Code: [Select]

          cd jan

          start /wait application_name.exe

          cd feb

          start /wait application_name.exe

          cd..

          cd mar

          start /wait application_name.exe

          cd..

          cd apr

          start /wait application_name.exe

          cd..

          cd may

          start /wait application_name.exe
          cd..

          cd jun

          start /wait application_name.exe

          cd..

          cd jul

          start /wait application_name.exe

          cd..

          cd aug

          start /wait application_name.exe

          cd..

          cd Sept

          start /wait application_name.exe

          cd..

          cd oct

          start /wait application_name.exe

          cd..

          cd nov

          start /wait application_name.exe

          cd..

          cd dec

          start /wait application_name.exe



          why not:

          Code: [Select]
          for %%P in (jan feb mar apr may jun July Sept Oct Nov Dec) do cd %P&start /wait application_name.exe@cd ..


          if the only folders are the month folders, it would be even simpler...

          Code: [Select]
          for %%P /D (*) do do cd %P&start /wait application_name.exe@cd ..

          I was trying to dereference Null Pointers before it was cool.

          blastman



            Hopeful

            Re: Batch file to unzip multiple files...
            « Reply #5 on: June 28, 2008, 01:36:35 AM »
            Code: [Select]
            for %%P /D (*) do do cd %P&start /wait application_name.exe@cd ..

            Show off!!!! ;) ;D

            I knew that it could be achived like that, but I wa unsure how. Could you break it down for me, what part of the syantx is doing what, so I konw for next time??

            cheers

            Blastman, you are the man. Thank You Very Much!!!!!!!!!



            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: Batch file to unzip multiple files...
            « Reply #6 on: June 28, 2008, 09:15:02 AM »
            oops- there is a mistake there- it should be:
            Code: [Select]
            for %%P /D (*) do cd %P&start /wait application_name.exe&cd ..

            I had do twice, and the @ sign instead of the & before cd ..


            the For /D command will iterate through all folders that match the given criteria. In this case, all of them (*) for each folder, I execute three commands (separated by &'s), first, change to the dir, then execute the program, then change back to the parent folder (cd ..)
            I was trying to dereference Null Pointers before it was cool.