2

I'm attempting to uncompress several .gz files using 7-Zip from the command line. My files are in directories like so:

Desktop/copyto/1/
    file1.gz
    file2.gz
Desktop/copyto/2/
    file1.gz
    file2.gz
    file3.gz

I would like to recursively uncompress all the .gz files into each's orginal location and as well as deleting the remaining .gz files when they are done uncompressing.

I have tried the following command with no luck:

7z.exe x C:\Users\MYUSERNAME\Desktop\copyto\*\*.gz -r

I assumed that this would extract recursively. I get the error:

Processing archive: C:\Users\MYUSERNAME\Desktop\copyto\1\file1.gz
Can not open output file file1
Sub items Errors: 1

Any idea what's going on?

codedude
  • 6,244
  • 14
  • 63
  • 99

1 Answers1

0

Given your command line, my guess is that your current working directory isn't any subdirectory of your home directory (C:\Users\MYUSERNAME) or the public user directory (C:\Users\Public), which means you probably don't have access rights. For example, if I run the following from C:\Program Files\7-Zip, I get the same error with a 7-Zip file:

C:\Program Files\7-Zip>7z x C:\Users\MYUSERNAME\Desktop\migrated\annex_k.7z -r

7-Zip [64] 9.38 beta  Copyright (c) 1999-2014 Igor Pavlov  2015-01-03

Processing archive: C:\Users\MYUSERNAME\Desktop\migrated\annex_k.7z

ERROR: Can not open output file : .\annex_k\include\annex_k\errno.h
Skipping    annex_k\include\annex_k\errno.h
ERROR: Can not open output file : .\annex_k\include\annex_k\handler.h
Skipping    annex_k\include\annex_k\handler.h
...
Extracting  annex_k\include\annex_k
Extracting  annex_k\include
Extracting  annex_k

Sub items Errors: 10

Archives with Errors: 1

Sub items Errors: 10

Kernel  Time =     0.031 =   39%
User    Time =     0.031 =   39%
Process Time =     0.062 =   78%    Virtual  Memory =      3 MB
Global  Time =     0.080 =  100%    Physical Memory =      4 MB

Notice that not even an annex_k directory was created:

C:\Program Files\7-Zip>dir /b
7-zip.chm
7-zip.dll
7-zip32.dll
7z.dll
7z.exe
7z.sfx
7zCon.sfx
7zFM.exe
7zG.exe
descript.ion
History.txt
Lang
License.txt
readme.txt

The solution is to extract to a directory in which you have access rights. You can specify an output directory using something like -oC:\Users\MYUSERNAME\Desktop\copyto\1. If you absolutely need to do this in a directory in which you don't have write access ordinarily, you'd need to run the command prompt as an administrator and extract the file as usual.