-r (Recurse subdirectories) switch

# -r (Recursive subdirectories for name search) switch

Specifies the method of recursive search for items that match to wildcard of filename specified on the command line.

Note: The -r (-r-) switch rules affect only searching phase of item (file or directory) with specified names. And if the directory is found for processing, 7-Zip will process also all subdirectories and all files of that directory and files of subdirectories, even if the search recursion is switched off with "-r-" switch.

#### Syntax

    -r[- | 0]

Switch | Description
--- | ---
-r | Enable recurse subdirectories for item search.
-r- | Disable recurse subdirectories for item search. This option is default for all commands.
-r0 | Enable recurse subdirectories for item search only for wildcard names.

#### Examples

    7z l archive.zip *.doc -r-

lists all *.doc files that belong to the archived root directory in the archive.zip archive.

    7z a -tzip archive.zip -r src\*.cpp src\*.h

adds all *.cpp and *.h files from directory src and all it's subdirectories to the archive.zip archive.

    7z a archive.7z folder1\

or

    7z a archive.7z -r- folder1\

adds all files from directory folder1 and all it's subdirectories to the archive.7z archive.

    7z a archive.7z -r folder2\

searches all folder2 directories in all subdirectories, and adds them (including all subdirectories) to the archive.7z archive.

#### Commands that can be used with this switch

a (Add), d (Delete), e (Extract), h (Hash), l (List), rn (Rename), t (Test), u (Update), x (Extract with full paths)

#### See also

Switches: -i (Include), -x (Exclude)