Perun2 is a free and open-source tool for creating filesystem automation plugins.
logo
To make them possible, it provides a tiny programming language that is...
logo
  • Statically typed
  • Declarative
  • Keyword-based
Compare it with several alternatives:
Open the freshest pdf file from this directory.
PowerShell
Get-ChildItem -Filter *.pdf | Sort-Object -Descending -Property CreationTime | select -First 1 | % {Invoke-Item $_.FullName}
Perun2
open '*.pdf'
  order by creation desc
  limit 1
Delete all empty directories from the directory tree, but only if their name is not src nor res.
PowerShell
Get-ChildItem $path -Recurse
-Directory | Where-Object { ($_.GetFiles().Count -eq 0)
-and ($_.Name -ne 'src')
-and ($_.Name -ne 'res') } |
% {Remove-Item $_.FullName}
Perun2
delete recursiveDirectories
  where empty
  and name not in ('src', 'res')
Move pdf files older than 9 days to the recycle bin.
Python
import os, time
from send2trash import send2trash

path = "c:\\somepath"
now = time.time()

for filename in os.listdir(path):
  p = os.path.join(path, filename)
  if os.path.isfile(p):
    if filename.endswith(".pdf"):
      filestamp = os.stat(p).st_mtime
      filecompare = now - 9 * 86400
      if filestamp < filecompare:
        send2trash(p)
Perun2
delete '*.pdf'
  where lifetime > 9 days
Of all directories here, hide these that do not contain any mp3 file.
C#
foreach(var d in Directory.GetDirectories("c://some//path"))
{
  if (!Directory.EnumerateFiles(d, "*.mp3") .Any())
  {
    DirectoryInfo di = Directory.CreateDirectory(d);
    di.Attributes = FileAttributes.Directory | FileAttributes.Hidden;
  }
}
Perun2
hide directories
  where not anyInside('*.mp3')
See more Perun2 code samples here.