Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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 professional system and network administrators.

6 Answers 6

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
4  
This wouldn't include any "hidden" files (eg. .htaccess) –  Sonassi Oct 5 '12 at 12:53
7  
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

You can use following syntax :

$ mv /source/* /dest/subfolder/

If you are still confuse then tell me exact location from which directory to which directory you want to move your data I will give you exact syntax.

share|improve this answer
    
-1 This is similar to the answer of @mulaz and there are the same drawbacks –  miracle173 Oct 11 '12 at 5:59

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

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

zsh:

mv /src/*(D) /dst/

(D) to include dot-files.

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)

IFS="
" && for f in $(ls -A); do mv "$f" /destination/"$f"; done
share|improve this answer

Your Answer

 
discard

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