Skip to content

What is the fastest way to move a million images from one directory to another in Linux?

An answer to this question on Super User.

Question

I have a million images that takes up 30GB of disk space that need to be moved from one local directory to another local directory.

What would be the most efficient way to do this? Using mv? Using cp? Using rsync? Something else?

I need to take these:

/path/to/old-img-dir/*
                     00000000.jpg
                     --------.jpg  ## nearly 1M of them! ##
                     ZZZZZZZZ.jpg

and move them here:

/path/to/new/img/dir/

Answer

rsync would be a poor choice because it does a lot of client/server background work which accounts for local as well as remote systems.

mv is probably the best choice. If possible, you should try mv directory_old directory_new rather than mv directory_old/* directory_new/. This way, you move one thing instead of a million things.