a (Add) command
Adds files to archive.
7z a archive1.zip subdir\
adds all files and subfolders from folder subdir to archive archive1.zip. The filenames in archive will contain subdir\ prefix.
7z a archive2.zip .\subdir\*
adds all files and subfolders from folder subdir to archive archive2.zip. The filenames in archive will not contain subdir\ prefix.
cd /D c:\dir1\ 7z a c:\archive3.zip dir2\dir3\The filenames in archive c:\archive3.zip will contain dir2\dir3\ prefix, but they will not contain c:\dir1\ prefix.
7z a Files.7z *.txt -r
adds all *.txt files from current folder and its subfolders to archive Files.7z.
7-Zip doesn't use the system wildcard parser. 7-Zip doesn't follow the archaic rule by which *.* means any file. 7-Zip treats *.* as matching the name of any file that has an extension. To process all files, you must use a * wildcard.
Switches that can be used with this command
-p (Set Password)
-sdel (Delete files after including to archive)
-sfx (create SFX)
-si (use StdIn)
-sni (Store NT security information)
-sns (Store NTFS alternate Streams)
-so (use StdOut)
-spf (Use fully qualified file paths)
-ssw (Compress shared files)
-stl (Set archive timestamp from the most recently modified file)
-t (Type of archive)
-w (Working Dir)