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

How can I move all files and folders from one directory to another via mv command?

share|improve this question

migrated from serverfault.com Oct 10 '12 at 16:34

This question came from our site for system and network administrators.

Try with this:

mv /path/sourcefolder/* /path/destinationfolder/
share|improve this answer
Thank you, I will try and come here with answer. – Luka Oct 5 '12 at 12:13
This wouldn't include any "hidden" files (eg. .htaccess) – Ben Lessani - Sonassi Oct 5 '12 at 12:53
Good point. If you are using bash, then you can run shopt -s dotglob and then "*" will match hidden files, too. – chutz Oct 5 '12 at 14:52
What happens if there are folders and files with the same name in the destination folder? Are they overwritten? – user1063287 Jun 14 at 1:08
... it seems folders with the same name are not overwritten. mv: cannot move '/a/js' to '/b/js': Directory not empty – user1063287 Jun 14 at 1:29

This works for me in Bash (I think this depends on your shell quite a bit...)

$  mv source/{,.}* /destination/folder/here
share|improve this answer
Actually, it shouldn't since in Bash source/{,.}* matches dir-entries named ./ and ../ – poige Oct 10 '12 at 21:48
. is skipped due to syntax, and .. is skipped too as it's identical in both locations (the mv command realizes this scenario). Your concern is noted, but the command does actually work. – Niall Byrne Oct 10 '12 at 22:39
When I try I get mv: overwrite 'destination/.'? mv: overwrite 'destination/..'?, but adding -n to mv stops it from trying to overwrite – Putnik Dec 5 '12 at 20:05
@Putnik - that's a good gotcha! what os/distro ? ( I was working on OSX when I was messing around with this...) – Niall Byrne Dec 7 '12 at 3:38
@Niall Byrne - I see the same prompt as Putnik. Using Ubuntu 14.04. – Mark Doliner Dec 23 '14 at 6:16


mv /src/*(D) /dst/

(D) to include dot-files.

share|improve this answer

I'd say it's a bit boring, but really bullet-proof (GNU) way is:

cd /SourceDir && find ./ -maxdepth 1 -mindepth 1 -exec mv -t /Target/Dir {} +

P. S. Now you can possibly see why lots of people do prefer Midnight Commander, though.

share|improve this answer

If you only want to do a cut and paste-like action there is a simple way that worked for me:

$mv /media/dir_source $HOME/Documents/ 

It will move the folder named dir_source located in /media to the directory $HOME/Documents/

share|improve this answer

This works for me in Bash 4.2.46, it moves all files and folders including hidden files and folders to another directory

mv /sourcedir/{,.[^.]}* /destdir/

Notice that .[^.]* means all hidden files except . and ..

share|improve this answer

yet another way just for the heck of it (because I love convoluted ways to do things I guess)

cd /source
for f in $(\ls -QA); do eval mv $f /destination/$f; done

the -Q and the -A are not POSIX, however the -A is fairly prevalent, and to not use the -Q you need to change the IFS (which then means you don't need the eval but need to quote the variable)

" && for f in $(ls -A); do mv "$f" /destination/"$f"; done
share|improve this answer
ls -Q doesn't output in a format that is suitable to use with eval or even $(...). Try after having run touch '$(reboot)' for instance (or touch '$(uname)' for a milder version). – Stéphane Chazelas Oct 8 '15 at 14:56
-A is now POSIX (since POSIX.1-2008). – Stéphane Chazelas Oct 8 '15 at 14:58

Your Answer


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