The first thing to do with files is to filter them by their extension. Extensions in Perun2 are always in lowercase. Even if certain file is seen as NAME.PDF in the file system.
If there are multiple extensions to check, we should use the In operator.
We can exclude one known file.
Files can be empty, hidden or read-only. This command also demonstrates how logical operators work.
Filter files by their name. This command will select files with name starting with the letter a. If you want to know more about the Like operator, go here. Variable name does not contain extension. If you want it included, you should use fullname instead.
Do exactly the same as above, but in different way. Indexing of characters in Perun2 is zero-based.
There is even a third way. We can use some intuitive functions designed for string manipulation: startsWith(), endsWith(), contains(), substring(), right() etc.
Perun2 contains a custom alternative to the Like operator. The Resembles operator checks if the text contains another text, but is very forgiving. It tolerates spelling mistakes (at most one for every 3 characters) and ignores case size. Go here to read about it. Code below would select a file with name containing text 'somthinng' (there are 2 spelling mistakes).
You can also use regular expressions if you understand them. Perun2 follows the ECMAScript regex convention and checks are case sensitive.
Restrict files by length of their name. As written before, variable name does not contain extension.
Find files created, recently modified or recently accessed today (or yesterday).
Find files created during the day that was 5 days ago.
Restrict files by their creation time.
Check creation year.
There are more possibilities: month, day, hour, minute, second. Even day of the week.
We can check the clock.
The same command could be written alternatively using the Between operator. This operator also works with other data types like numbers or strings.
Restrict files by their size. Petabyte (pb) is the greatest available unit for number suffix.
Check how old files are. Variable lifetime expresses the difference between current moment in time and the oldest of two values: file creation time and last modification time. We can use various units, from seconds to years.
Find the top 10 largest files.
Statements where, limit, order by are called filters. Filters are performed sequentially one by one. All filters are explained here.
We can do the same by using index. Indexing is zero-based, so the first element has index 0 and so on.
Delete all pdf files except for the 100 recently created.
Previous commands featured the order by filter. It sorts files by a value ascendingly or descendingly (keyword asc or desc). We can use multiple values for order. Below is an example. We order pdf files based on their name length from the shortest to the longest. If two files have exactly the same name length, then they are compared again by the year of their creation.