How to move all files and folders via mv command

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

Asked By: Luka


Try with this:

mv /path/sourcefolder/* /path/destinationfolder/
Answered By: mulaz

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

$  mv source/{,.}* /destination/folder/here
Answered By: Niall Byrne

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.

Answered By: poige


mv /src/*(D) /dst/

(D) to include dot-files.

Answered By: Stéphane Chazelas

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
Answered By: Drake Clarris

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/

Answered By: user141726

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 ..

Answered By: Jun
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.