How to batch compress videos and images from the command line on a Mac
macOS already has two command-line tools for this: avconvert re-encodes videos to a preset such as 1280×720, and sips resizes or recompresses images, and both can be run in a for loop over a folder; FFmpeg, installed with Homebrew, gives finer control. None of them aims at a file size, so for “every file under 20 MB” in one line, install SendSize's sendsize command from Settings → Automation and run sendsize compress on the folder with --preset discord or --max-mb.
Compress without opening the window Watch folders, clipboard, links, command line
Videos with avconvert (built in)
avconvert comes with macOS and uses the Mac's own encoder. avconvert --help lists its presets. This loop makes a 720p copy of every MOV in the current folder:
for f in *.mov; do avconvert --source "$f" --preset Preset1280x720 --output "${f%.*}-720p.mp4"; done
Images with sips (built in)
sips changes the files you give it unless you add --out. Work on a copy of the folder. This makes every JPEG at most 2000 pixels on the long side and saves it at quality 70 into a folder called small:
mkdir -p small; for f in *.jpg; do sips -Z 2000 -s formatOptions 70 "$f" --out small/; done
Videos with FFmpeg
FFmpeg is free and open source; install it with brew install ffmpeg. CRF sets the quality instead of the size: 23 is the default, higher numbers give smaller files. The loop below keeps the resolution and re-encodes to H.264:
for f in *.mov; do ffmpeg -i "$f" -c:v libx264 -crf 26 -preset slow -c:a aac -b:a 128k "${f%.*}-small.mp4"; done
One command with a target size: sendsize
For videos it works out the bitrate from the length and encodes in two passes with x264, then tries a lower resolution if the file is still too big, up to 3 times. sendsize presets lists every use and sendsize with no arguments prints all options; the automation page explains each one.
- In SendSize, open Settings → Automation and click Install… under Terminal. It makes /usr/local/bin/sendsize, a link to the tool inside the app.
- Open a new Terminal window.
sendsize compress ~/Movies/Trip --preset discordcompresses every video, photo, GIF and PDF in the folder and its subfolders so each file is under 20 MB. - Use
--max-mb 8for a size of your own, or--preset gmailfor an email (under 25 MB). Without a preset it uses Compress: smaller, quality first, no target. - Choose where results go: by default a new folder next to the originals;
--suffix -smallnext to each file;--subfolder Smallerinside each folder;--out ~/Desktop/Sendinto one folder;--replacein place of the originals, which go to the Trash.
In scripts
- Exit code 0 means every file worked, 1 that a file failed, 2 a wrong option.
- Files SendSize already made are skipped, so a script that runs every night does not compress the same files again. Add
--forceto do them anyway. - One line per file is printed with the size before and after, then a summary.
What to keep in mind
- The sendsize command follows the app's license: the free version compresses 5 files at a time and says so; the $19.99 license removes the limit.
- avconvert and sips are part of macOS; their presets and options can change with macOS versions.
avconvert --helpandman sipsshow what your Mac has. - WebM and MKV are not converted in version 1.0.
Questions
How do I compress a video from the Mac command line without installing anything?
Use avconvert, which comes with macOS: avconvert --source in.mov --preset Preset1280x720 --output out.mp4.
How do I batch resize images in Terminal on a Mac?
sips -Z 2000 *.jpg resizes every JPEG in the folder to at most 2000 pixels on the long side. It overwrites the files unless you add --out.
How do I compress every file under a certain size from the command line?
FFmpeg and avconvert do not aim at a size. sendsize compress <folder> --max-mb 20 does, for videos, photos, GIFs and PDFs.
Where does the sendsize command come from?
It ships inside SendSize. Settings → Automation → Install… puts a link to it in /usr/local/bin, and Remove takes it away.
Sources
- Discord: File Attachments FAQ (checked November 16, 2026)
- Gmail Help: Send attachments with your Gmail message (checked November 16, 2026)
Do it with SendSize
Compress without opening the window
PresetWatch folders, clipboard, links, command line
- Watch folders and the clipboard: turn them on in the app (license).
- Links and the sendsize command: Settings → Automation.
- The results land where a normal batch would put them.
Free for 5 files at a time. $19.99 once for any number, on 3 Macs.