Recurse Subdirectories

Help
roland
2005-02-22
2012-12-07
  • roland

    roland - 2005-02-22

    Hello,

    I have multiple .gz file in multiple subdirectories.  How can I recurse the directory structure to uncompress these .gz files within their respective subdirectories?

    I am attempting to do this with the 7z.exe command line tool.

    For example:
    7z -r0 e *.gz

    does not work.  "There is not such archive" is returned.  What is the appropriate syntax for doing this?  Any help would be appreciated.

    Thanks,
    Roland

     
    • Nobody/Anonymous

      for /r %I in (*.gz) do 7z x %I

      will do what you want

       
    • roland

      roland - 2005-02-23

      Thanks Anonymous,

      This appears to be the syntax for Windows XP and it is certainly a postitive step forward.  I believe the syntax for Windows 2000 is slightly different:

      FOR /R %%I IN (*.gz) DO 7z x %%I

      However, there is still a challenge here.  The .gz files get extracted to the folder where the command was run, not into their respective folders.  How can I have the files get extracted into their respective folders, rather than all into the one folder?

      For example:

      From this:
      f:\data\folder1\file.gz
      f:\data\folder2\file.gz
      f:\data\folder3\file.gz

      I would like this:
      f:\data\folder1\file.tar
      f:\data\folder2\file.tar
      f:\data\folder3\file.tar

      Thanks,
      Roland

       
    • roland

      roland - 2005-02-23

      Correction:

      FOR /R %%I IN (*.gz) DO 7z x %%I

      I just noticed that the double percent signs are needed because I have included the command in a batch file, not specific to Windows XP or 2000.

      The challenge is still how do I get the files to extract in their respective folders?

      Thanks In Advance,
      Roland

       
      • PatLogan

        PatLogan - 2005-02-23

        hi mrduhaime,

        an idea :
        with xcopy /L /S c:\*.gz d:, you can have the list of the *.gz files in c: (the destination [here d:] must be an other directory, of course.

        you can do :
        for /f "tokens=1" %%i in (xcopy /l /s c:\*.gz d:) do 7z x %%i -o%%~dpi

        type for /? in the shell to have explanations of %~dpi and tokens in your langage (i have it in french...)

        I tried with do echo to verify, if the 7z syntax is good, it should work

        ++

        Pat

         
        • PatLogan

          PatLogan - 2005-02-23

          uh!
          sorry
          it was
          for /f "tokens=1" %%i in ('xcopy /l /s c:\*.gz d:') do 7z x %%i -o%%~dpi
          with ' before and after the command beetwen the ()
          but your solution is nicer, didn't know it would work ;)

          thx!

          Pat

           
    • roland

      roland - 2005-02-23

      Thanks Pat,

      Using this syntax I get the following error:

      "The system cannot find the file xcopy."

      Even though xcopy is in the path and I am able to run it at command line.

      This sure is a puzzle.

      Roland

       
    • roland

      roland - 2005-02-23

      Here is the solution.  Thanks to Pat and Anonymous for leading me there.

      FOR /R %%I IN (*.gz) DO 7z x %%I -o%%~dpI

      I am confident that this will be helpful to someone else.

      All The Best,
      Roland

       

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks