Move/Copy many files in bash

Alec Jacobson

March 17, 2014

weblog/

I tried to move a bunch (>30,000) of files starting with the same prefix to a new directory:

mv color-*.png ../some-other-dir/

But I got the error:

-bash: /bin/mv: Argument list too long

Instead, I used:

find . -name "color-*.png" -exec mv {} ../some-other-dir/ \;

Note that the {} will get replaced with the individual file names and the mv command is executed separately for each.

source