7-Zip Manual

Documents 7-Zip 26.04

All documents
Start and general
  • 7-Zip Start Page
  • General Information
  • 7z Format
  • Frequently Asked Questions (FAQ)
  • Supported formats
  • License for use and distribution
  • Performance
  • Thanks
File Manager
  • 7-Zip File Manager
  • About Dialog Box
  • Benchmark
  • Menu Items and Shortcut Keys
  • Options Dialog Box
  • Delete Temporary Files
File Manager plugins
  • 7-Zip Plugin
  • Plugins
  • Add to Archive Dialog Box
  • Extract Dialog Box
Command line: overview
  • Command Line Version User's Guide
  • Exit Codes from 7-Zip
  • Command Line Syntax
Command line: commands
  • Command Line Commands
  • a (Add) command
  • b (Benchmark) command
  • d (Delete) command
  • e (Extract without folders) command
  • x (Extract with full paths) command
  • h (Hash) command
  • l (List contents of archive) command
  • rn (Rename) command
  • t (Test integrity of archive) command
  • u (Update) command
Command line: switches
  • Command Line Switches
  • -ax (Exclude archive filenames) switch
  • -ai (Include archive filenames) switch
  • -an (Disable parsing of archive_name) switch
  • -bb (Set output log level) switch
  • -bs (Set output stream for output/error/progress line) switch
  • -scs (Set charset for list files) switch
  • -seml (Send archive by email) switch
  • -x (Exclude filenames) switch
  • -i (Include filenames) switch
  • -slp (Set Large Pages mode) switch
  • -slt (Show technical information) switch
  • -m (Set compression Method) switch
  • -o (set Output directory) switch
  • -ao (Overwrite mode) switch
  • -p (set Password) switch
  • -r (Recurse subdirectories) switch
  • -sa (set Archive name mode) switch
  • -scc (Set charset for console input/output) switch
  • -scrc (Set hash function) switch
  • -sdel (Delete files after including to archive) switch
  • -sfx (Create SFX archive) switch
  • -ssw (Compress files open for writing) switch
  • -sni (Store NT security information) switch
  • -sns (Store NTFS alternate Streams) switch
  • -spf (Use fully qualified file paths) switch
  • -spm (Require path separator mark for directory path) switch
  • -ssc (Set Sensitive Case mode) switch
  • -si (read data from stdin) switch
  • -so (write data to stdout) switch
  • -stl (Set archive timestamp from the most recently modified file) switch
  • -- (Stop switches parsing) switch
  • -stx (Exclude archive type) switch
  • -t (set Type of archive) switch
  • -u (Update options) switch
  • -v (Create Volumes) switch
  • -w (set Working directory) switch
  • -y (assume Yes on all queries) switch
Text files
  • 7zC.txt
  • 7zFormat.txt
  • License.txt
  • Methods.txt
  • copying.txt
  • lzma.txt
  • readme.txt
  • src-history.txt
  • unRarLicense.txt
  1. 7-Zip Manual
  2. Command line: commands
  3. rn (Rename) command

rn (Rename) command

Renames files in archive.

Syntax

rn <archive_name> <src_file_1> <dest_file_1> [ <src_file_2> <dest_file_2> ... ]

Example

7z rn a.7z old.txt new.txt 2.txt folder\2new.txt 

renames old.txt to new.txt and 2.txt to folder\2new.txt .

Notes

Switches that can be used with this command

-i (Include)
-m (Method)
-p (Set Password)
-r (Recurse)
-stl (Set archive timestamp from the most recently modified file)
-u (Update)
-w (Working Dir)
-x (Exclude)

Notes from this site

Not part of the 7-Zip manual. Written by this site; examples checked with 7-Zip 26.04.

Quick examples

The official Linux and macOS console binary is 7zz. On Linux and macOS write folder paths with /.

7zz rn a.7z old.txt new.txt
7zz rn a.7z 2.txt folder/2new.txt           # move into a folder
7zz rn a.7z oldfolder newfolder
7zz rn a.7z "old name.txt" "new name.txt"   # quote names with spaces
7zz rn -pSECRET a.7z old.txt new.txt        # needed when file names are encrypted

Check the result with 7zz l a.7z. Case-only renames and adding a root folder (f/d.log to v1/f/d.log) work. Archives that encrypt only contents (no -mhe) can be renamed without the password.

The vendor example folder\2new.txt is the Windows form (7z rn a.7z 2.txt folder\2new.txt). On Linux and macOS a backslash becomes part of the name: the entry is literally called folder\2new.txt and no folder is created.

How do I rename many files at once?

Wildcards are rejected, so build the name pairs from the listing. This renames every .txt to .md:

args=()
while IFS= read -r p; do args+=("$p" "${p%.txt}.md"); done < <(
  7zz l -slt -ba a.7z | sed -n 's/^Path = \(.*\.txt\)$/\1/p')
7zz rn a.7z "${args[@]}"

How it behaves

  • Arguments come in pairs: old name, new name, as stored in the archive (see 7z l).
  • Renaming a folder entry renames everything under it. Renaming to a path with a new folder part moves the file there.
  • It works on formats 7-Zip can write (tested: 7z, zip, tar), not on .rar.
  • The whole archive is rewritten, so keep a copy; solid 7z archives take longer. For a big archive, -w chooses where the temporary file goes.

How do I rename inside a .tar.gz?

7zz x t.tgz                     # gives t.tar
7zz rn t.tar f/a.txt f/z.txt
7zz a -tgzip t.tgz t.tar        # recompress, replacing t.tgz

Common mistakes

  • Wildcards: 7zz rn a.7z '*.txt' x.txt fails with "Unsupported rename command" (exit code 7). Rename one name at a time.
  • Renaming onto a name that already exists does not fail and does not overwrite: the archive then holds two entries with that name. Check with 7zz l first.
  • Renaming inside a .tar.gz fails. Unpack the .tar layer, rename there, and compress again (see "How do I rename inside a .tar.gz?" above).
  • An odd number of names stops with "There is no second file name for rename pair" (exit code 7).

Related pages

  • u (Update), d (Delete), l (List)
Previousl (List contents of archive) commandNextt (Test integrity of archive) command

This is an unofficial mirror of the 7-Zip documentation. This site is not affiliated with, endorsed by, or sponsored by 7-Zip or its authors. The documentation (7-Zip 26.04) is copyright © 1999-2026 Igor Pavlov and any other rights holders, and is licensed under the GNU LGPL.

Source: 7-zip.org (downloads and current release). The 7-Zip text is unmodified; only the page layout is changed. Boxes titled “Notes from this site” are written by this site and are not part of the 7-Zip manual.