Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is it possible to make 7Zip extract one file by name from archive to specified full path (including new filename)?

I've found only:

7zip e <archive> -o<resultDirectory> <filemask>

But it's not what I need.

share|improve this question
    
What you have tried, and what was not working? –  Maximus Feb 3 at 14:33
    
@Maximus, I have tried to search in Google and read manuals. And I have drawn a conclusion that there is no way to extract file from an archive so that result file would have specified name (not the same as inside the archive) using only commands of 7zip. –  SerG Feb 3 at 15:04

1 Answer 1

up vote 2 down vote accepted

You can use the -so option to write the data to stdout and redirect to your target file:

Example:

7z e -so xxxx.7z > yyy.txt

The commandline help of version 9.22 beta:

7-Zip [64] 9.22 beta  Copyright (c) 1999-2011 Igor Pavlov  2011-04-18

Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...]
       [<@listfiles...>]

<Commands>
  a: Add files to archive
  b: Benchmark
  d: Delete files from archive
  e: Extract files from archive (without using directory names)
  l: List contents of archive
  t: Test integrity of archive
  u: Update files to archive
  x: eXtract files with full paths
<Switches>
  -ai[r[-|0]]{@listfile|!wildcard}: Include archives
  -ax[r[-|0]]{@listfile|!wildcard}: eXclude archives
  -bd: Disable percentage indicator
  -i[r[-|0]]{@listfile|!wildcard}: Include filenames
  -m{Parameters}: set compression Method
  -o{Directory}: set Output directory
  -p{Password}: set Password
  -r[-|0]: Recurse subdirectories
  -scs{UTF-8 | WIN | DOS}: set charset for list files
  -sfx[{name}]: Create SFX archive
  -si[{name}]: read data from stdin
  -slt: show technical information for l (List) command
  -so: write data to stdout
  -ssc[-]: set sensitive case mode
  -ssw: compress shared files
  -t{Type}: Set type of archive
  -u[-][p#][q#][r#][x#][y#][z#][!newArchiveName]: Update options
  -v{Size}[b|k|m|g]: Create volumes
  -w[{path}]: assign Work directory. Empty path means a temporary directory
  -x[r[-|0]]]{@listfile|!wildcard}: eXclude filenames
  -y: assume Yes on all queries

More recent alpha versions (9.30) also do not allow to specify a target filename as direct parameter without redirection.

share|improve this answer
    
Such method leads to redirection the whole informational output too and demands additional filtering. Cause I use 7Zip from c# (as more stable alternative to ionic DotNetZip), I just manipulate folders and file to acheave my goal. Also I seen somwhere, that there is -rn option, that allows to rename a file inside the archive, but it's said also have a performance issue. –  SerG Feb 3 at 18:35
    
Are you sure? I've tried it from a cmd.exe box and the resulting file looks fine. It might help to redirect channel 2 (stderr) separately from stdout. –  Axel Kemper Feb 3 at 19:04
    
I'm not sure, but: this. –  SerG Feb 3 at 19:08
1  
Yes. You get this error if you just use -so without actually redirecting stdout to a file. But as soon as you add "> yyy.txt", it works flawlessly. Calling 7z embedded from c# is a different matter beyond your original question. –  Axel Kemper Feb 3 at 19:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.