Earlier quoted context omitted.
The with-current-directory part is the dynamic part - i.e. within its dynamic scope, the current directory is now dir. The scoping of the dir variable itself is irrelevant.
`with-current-directory` has to be a macro because if it is not, then the evaluation of (delete-all-files-recursively) happens before the definition of with-current-directory can change the current directory. What the person meant when he wrote, "In those times I wish I could use the emacs lisp way," is, "In those times I wish I could use a lisp _macro_" -- particularly, one of those macros that makes a change, runs…
with-auto-compression-mode with-case-table
with-category-table with-coding-priority
with-current-buffer with-decoded-time-value
with-demoted-errors with-electric-help
with-help-window with-local-quit
with-no-warnings with-output-to-string
with-output-to-temp-buffer with-selected-frame
with-selected-window with-silent-modifications
with-syntax-table with-temp-buffer
with-temp-buffer-window with-temp-file
with-temp-message with-timeout
with-timeout-suspend with-timeout-unsuspend
with-wrapper-hook