Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to batch copy/move files in unix? I thought it might be an option for cp/mv but I can't find any way to do it.

share|improve this question
cp and mv are pretty good choices. What additional features do you need? For renaming, see unix.stackexchange.com/q/1136/8250 – Lekensteyn May 6 '12 at 17:47
Yes there is. What files are you going to copy/move? – user13742 May 6 '12 at 18:39
What exactly do you mean by "batch copy" that you couldn't get done by cp or mv? – Mat May 6 '12 at 18:39
@Lekensteyn and Mat: I'm trying to move every file in a directory I extracted from an archive into the directory aforementioned directory is contained in. – rake May 6 '12 at 18:57

cp and mv are both good tools for copying files and moving files respectively. Combined with shell constructs (loops like for file in *; do ...; done) or find, they become even more powerful.

If I understood your purpose correctly, you have extracted files like:


and want to move all files into the parent directory such that it looks like:


Using shell wildcards, assuming that you are in the directory somedir, you can use:

mv * ../

* is a glob pattern that expands to all files in the current directory. If you have hidden files (files and directories with a leading . in their filename), use shopt -s dotglob in bash).

I've mentioned find before. If you have a tree of files like:


and want to move all files in one directory (say, seconddir), use:

find -exec mv {} seconddir/ \;

This assumes that all filenames are unique, otherwise files would get overwritten.

share|improve this answer

You might get away nicely with rename as it's more apt to batch processing.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.