Everywhere All articles Download

Command line and power tools

From a list of files to an action on each

Updated 2026-08-08 · 4 min read

Every file task has two halves: producing the list, and acting on it. find and searches produce lists; xargs is the standard bridge that feeds a list to any command — once you know the one flag pair that keeps filenames with spaces from shredding everything.

The canonical pair

find ~/Downloads -name "*.dmg" -print0 | xargs -0 rm

-print0 and -0 are non-negotiable on a Mac: they delimit filenames with a null byte instead of whitespace, so Install macOS Sequoia.dmg arrives at rm as one argument, not three. Every space-related xargs disaster traces to omitting this pair.

Preview first, always — swap the destructive command for echo:

find ~/Downloads -name "*.dmg" -print0 | xargs -0 echo rm

prints the exact commands without running them.

Placing the filename mid-command

By default xargs appends arguments at the end. When the command needs the name elsewhere — or once per file — use -I{}:

find . -name "*.heic" -print0 |   xargs -0 -I{} sips -s format jpeg {} --out converted/{}.jpg

-I implies one command per file, which is slower and sometimes exactly right (per-file output paths, commands that take one input).

Parallelism for free

find . -name "*.wav" -print0 | xargs -0 -P 4 -n 1 ~/bin/compress-audio.sh

-P 4 runs four at once, -n 1 gives each invocation one file. For CPU-bound per-file work — transcoding, OCR, compression — this alone uses the cores a plain loop leaves idle.

When you do not need it

find's own -exec cmd {} + covers the simple append case with no quoting concerns at all, and a zsh for f in **/*.pdf loop reads better for multi-step logic. xargs earns its place at the seams: piping *any* list producer — mdfind, grep -l, a file of paths, a search tool's output — into any consumer, with -0 as the safety interlock and -P as the turbocharger.

Common questions

Why did xargs mangle filenames with spaces?

The input was whitespace-delimited. Produce it with -print0 and read it with -0; the null-delimited pair is immune to any filename.

xargs or find -exec?

-exec for simple cases directly inside find; xargs when the list comes from elsewhere, needs -I placement, or benefits from -P parallelism.

Find any file before you finish typing

Everywhere keeps track of every file on your Mac — including the folders Spotlight hides and drives you have unplugged. Free for a day, then $19 once.

Download for Mac

Version 2.15.7 · macOS 13+ · 3.8 MB · notarised

Related

© 2026 Caretopia Network Private Limited Everywhere for Mac Articles Privacy Support