Guide 4 - Recursive

Commands from previous pages operated on files and directories only from current working location. We did not go any deeper into the directory tree. We can get this change by replacing keywords files and directories with recursiveFiles and recursiveDirectories.

copy recursiveFiles
  where extension in ('pdf', 'doc', 'txt')

Find all files with name data.json or info.json in the entire directory tree. Copy them to the clipboard (the clipboard is flushed before this operation).

copy recursiveFiles
  where fullname in ('data.json', 'info.json')

We can impose limitation on depth of elements. Look at the code below. Depth 0 means, that certain file or directory lies directly in current working location. For every visited directory, this value is increased by one. For example, 'dir/dir2/name.pdf' has depth 2.

delete recursiveDirectories
  where empty
  and depth <= 3

There is a nice and concise Asterisk Pattern that expresses all pdf files from the entire directory tree. It is written in the code below. We can also access the property depth here as well.

copy '**.pdf' to 'f:/'

Perun2 has two special values: * and **. Single asterisk means all files and directories from current working location without recurrence.

select *

On the other hand, ** means all files and directories from the entire directory tree.

unhide ** where hidden
Next