-y (assume Yes on all queries) switch
Disables most of the normal user queries during 7-Zip
execution. You can use this switch to suppress overwrite queries in the
e (Extract) and
x (Extract with full paths) commands.
Syntax
-y
Examples
7z x src.zip -y
extracts all files from
src.zip archive. All overwrite queries will be
suppressed and files on disk with same filenames as in archive will be
overwritten.
Commands that can be used with this switch
e (Extract) ,
x (Extract with full paths)
See also
Switches:
-ao (Overwrite mode) ,
Notes from this site
Not part of the 7-Zip manual. Written by this site; examples checked with 7-Zip 26.04.
How do I stop the overwrite prompt in a script?
On Linux and macOS the official console binary is 7zz; on Windows it is 7z.
7zz x src.zip -y -o./out # always overwrite
7zz x src.zip -aou -o./out # safest: keep both, the new file gets a _1 suffix
7zz x src.zip -aos -o./out # keep existing files, skip clashes
7zz x enc.7z -y -psecret -o./out
7zz x src.zip -y -o./out -bso0 -bsp0 # quiet log
7z x src.zip -y -oC:\out
Warning: in a script -y silently overwrites existing files. After -aou the folder held a.txt (old) and a_1.txt (from the archive). The output folder is created if it does not exist. -y does not silence normal output; add -bso0 -bsp0 (see -bs ) for a quiet log. You do not need -y with t or l; both accept it, and neither overwrites anything.
-y vs -ao: which should I use?
Without -y, a clash stops at "(Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all / (Q)uit?". With -y the answer is always yes. If you also give -ao, that switch decides what happens to existing files (-y -aos kept the old file in a test), so pick one. For extraction scripts, -aoa (overwrite all) says what it does more clearly than -y.
Common mistakes
Expecting -y to supply a password: an encrypted archive still asks "Enter password:" and, if input is closed, stops with exit code 255. Add -p (see -p , which covers quoting a password).
Running a script without -y or -ao: it waits at the prompt, or stops with exit code 255 when input is closed.
Relying on -y with a or d: both accept it without error, but the vendor text documents it only for e and x, so what it answers there is not documented.
Related pages