Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I would like to know how could I move all files from a folder to another folder with a command line.

Let's say I'm in my Downloads folder and there are a 100 files that I would like to move to my Videos folder, without having to write all the files name.

share|improve this question

3 Answers 3

To do so, Open a terminal and execute this command:

mv  -v ~/Downloads/* ~/Videos/

It will move all the files and folders from Downloads folder to Videos folder.


To Move all files, but not folders:

But, If you are interested to move all files (but not folders) from Downloads folder to Videos folder, use this command

find ~/Downloads/ -type f -print0 | xargs -0 mv -t ~/Videos

To move only files from the Download folders, but not from sub-folders:

If you want to move all files from the Downloads folder, but not any files within folders in the Download folder, use this command:

find ~/Downloads/ -maxdepth 1 -type f -print0 | xargs -0 mv -t ~/Videos

here, -maxdepth option specifies how deep find should try, 1 means, only the directory specified in the find command. You can try using 2, 3 also to test.

See the Ubuntu find manpage for a detailed explanation

share|improve this answer
1  
you can use mv alone to move an entire directory to another folder: mv folder ~/Documents –  JohnMerlino Aug 9 at 22:42
  1. Go to the command line and get into the directory you want to move it to with cd folderNamehere
  2. Type pwd. This will print the directory you want to move it too.
  3. Then change to the directory where all of the files are with cd folderNamehere
  4. Now to move all the files type mv *.* typeAnswerFromStep2here

That will move all files from that directory to the other.

share|improve this answer
    
This will not match files without any extension. for example if a folder has the files: foo.txt, bar. and bar both bar. and bar will not be moved. Using * instead of *.* takes care of that. But in both cases, hidden files like: .foobar will not be moved. –  Dan Sep 12 '13 at 14:20
mv -R ~/Downloads ~/Videos

Where -R means recursively, and will move all the files including sub-folders in the directory you want to cp, mv, or rm.

share|improve this answer

Your Answer

 
discard

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.