How do I move all files from one folder to another using the command line?












185















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

























  • You're asking about moving files but people showing you how to move not only files but foldersas well. Is that OK?

    – Askar
    Feb 26 '15 at 1:35
















185















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

























  • You're asking about moving files but people showing you how to move not only files but foldersas well. Is that OK?

    – Askar
    Feb 26 '15 at 1:35














185












185








185


62






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
















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.







command-line






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 6 '12 at 15:24









ish

115k29265293




115k29265293










asked Aug 6 '12 at 15:14









MichaelMichael

926273




926273













  • You're asking about moving files but people showing you how to move not only files but foldersas well. Is that OK?

    – Askar
    Feb 26 '15 at 1:35



















  • You're asking about moving files but people showing you how to move not only files but foldersas well. Is that OK?

    – Askar
    Feb 26 '15 at 1:35

















You're asking about moving files but people showing you how to move not only files but foldersas well. Is that OK?

– Askar
Feb 26 '15 at 1:35





You're asking about moving files but people showing you how to move not only files but foldersas well. Is that OK?

– Askar
Feb 26 '15 at 1:35










9 Answers
9






active

oldest

votes


















261














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:



If you are interested in moving 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





















  • 3





    you can use mv alone to move an entire directory to another folder: mv folder ~/Documents

    – JohnMerlino
    Aug 9 '14 at 22:42






  • 14





    FYI I believe your first command ("mv -v ~/Downloads/* ~/Videos/") won't move dot files.

    – Mark Doliner
    Dec 23 '14 at 6:11











  • Yes, It won't move the .files

    – Anwar
    Dec 24 '14 at 18:11






  • 3





    Nb. your -print0 | xargs -0 mv -t ~/Videos can be more efficiently done with -exec mv -t ~/Videos {} + :-)

    – artfulrobot
    Jun 9 '15 at 13:46






  • 1





    mv -v ~/Downloads/* ~/Videos/ does not work for hidden files

    – FreeLightman
    Mar 18 '18 at 15:20



















19














mv ~/Downloads/* ~/Videos


It will move all the files including subfolders in the directory you want to mv. If you want to cp (copy) or rm (remove) you will need the -r (recursive) option to include subfolders.






share|improve this answer





















  • 2





    My mv command doesn't have a -R option (Ubuntu 14.04).

    – Mark Doliner
    Dec 23 '14 at 6:10











  • @MarkDoliner, yes, mv doesn't need recursive option to include subfolders. One can use it also for renaming.

    – AliNâ
    Jan 25 '15 at 23:26











  • I didn't need * . Same thing happened without using the star.

    – MycrofD
    Mar 22 '17 at 13:28











  • The ~/ in the prefix of the folder names doesn't always work (doesn't work on bash and git atleast)

    – Krish Munot
    Jun 6 '17 at 23:00











  • This solution will give an error if the source directory is empty.

    – Pierre Thibault
    Jul 26 '18 at 13:04



















6














It's possible by using rsync, for example:



rsync -vau --remove-source-files src/ dst/


where:




-v, --verbose: Increase verbosity.



-a, --archive: Archive mode; equals -rlptgoD (no -H, -A, -X).



-u, --update: Skip files that are newer on the receiver.



--remove-source-files This tells rsync to remove from the sending side the files (meaning non-directories) that are a part of the transfer and have been successfully duplicated on the receiving side.




If you've root privileges, prefix with sudo to override potential permission issues.






share|improve this answer





















  • 1





    WARNING! the --delete-after option as noted doesn't work the way you might expect. It doesn't delete the source files after successful copy... IT DELETES ALL THE REMAINING/OTHER FILES IN THE DESTINATION. (as @kenorb noted... but I didn't read carefully enough! DOH)

    – Jay Marm
    Aug 10 '18 at 4:06





















3














Use



mv -v ~/rootfolder/branch/* ~/rootfolder


I hope this helps. Because I had the same pain and wasted a lot of time fixing my mistake.






share|improve this answer































    3














    For the simple case:



    mv ~/Downloads/* ~/Videos


    If you want to move dot files too, then set the dotglob shell option.



    shopt -s dotglob
    mv ~/Downloads/* ~/Videos


    This leaves the shell option set.



    For one time dotglob use, run the commands in a subshell:



    (shopt -s dotglob; mv ~/Downloads/* ~/Videos)





    share|improve this answer































      1















      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





















      • 3





        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





















      0














      To move a directory with or without content to its new name just like how you would use the mv command to rename a file:



      mv -T dir1 dir2



      where:





      • -T treats the destination as a normal file


      • dir1 is the original name of the directory


      • dir2 is the new name of the directory


      NB: dir2 doesn't have to exist.



      I hope this saves someone a lot of time, as a noob, before this, I would create a directory with the new name and then move the contents of the directory to the directory created earlier.



      Use for subdirectories



      This command is useful when many files have been saved in a subfolder of the target directory i.e. Downloads/mp4. In this example, running mv -T Downloads/mp4 Videos will result in mp4 subfolder being removed and all files contained inside are moved to Videos folder.






      share|improve this answer





















      • 1





        +1 because tested working in Xubuntu 14.04. I have added an example in this answer to show that this command will cause the dir1 to be removed. Aside from this precaution, this answer has noted something good for daily use.

        – clearkimura
        Dec 9 '15 at 8:45






      • 1





        "To move a directory with or without content to its new name" How can you move a directory...to a name? That makes no sense. "-T treats the destination as a normal file" How can a destination be a file? Do you mean directory?

        – Monica Heddneck
        Apr 29 '17 at 23:55











      • Its like renaming a file to its new name like you would do with something like mv fileA fileB but the -T flag in this case treats the destination/directory as a file and renames it.

        – Feyisayo Sonubi
        Apr 30 '17 at 22:10



















      0














      try it



      find ~/Desktop -type f -iname  "*.mp4" -exec mv {} ~/Videos ;


      -type
      with the argument -type you can specify type file.on this statement that is the mean file.if using of -d that means directory.



      -iname:
      the most common and obvious method to look for a file is using its -name argument.if you are not sure about its case-sensitivity you can use of -iname argument



      mv {}
      and finally to specify target directory and then moving the files on there using mv {} argument






      share|improve this answer































        0














        mv source_path/* destination_path/


        here you have to put forward slash and * after source path so that it will take files inside source_path instead of the complete source directory.



        Example: mv /home/username/test/* /home/username/test2/



        The above command moves all files (unless they are hidden) in the source directory to the destination directory.






        share|improve this answer










        New contributor




        vivek Kumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.




















          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f172629%2fhow-do-i-move-all-files-from-one-folder-to-another-using-the-command-line%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          9 Answers
          9






          active

          oldest

          votes








          9 Answers
          9






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          261














          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:



          If you are interested in moving 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





















          • 3





            you can use mv alone to move an entire directory to another folder: mv folder ~/Documents

            – JohnMerlino
            Aug 9 '14 at 22:42






          • 14





            FYI I believe your first command ("mv -v ~/Downloads/* ~/Videos/") won't move dot files.

            – Mark Doliner
            Dec 23 '14 at 6:11











          • Yes, It won't move the .files

            – Anwar
            Dec 24 '14 at 18:11






          • 3





            Nb. your -print0 | xargs -0 mv -t ~/Videos can be more efficiently done with -exec mv -t ~/Videos {} + :-)

            – artfulrobot
            Jun 9 '15 at 13:46






          • 1





            mv -v ~/Downloads/* ~/Videos/ does not work for hidden files

            – FreeLightman
            Mar 18 '18 at 15:20
















          261














          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:



          If you are interested in moving 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





















          • 3





            you can use mv alone to move an entire directory to another folder: mv folder ~/Documents

            – JohnMerlino
            Aug 9 '14 at 22:42






          • 14





            FYI I believe your first command ("mv -v ~/Downloads/* ~/Videos/") won't move dot files.

            – Mark Doliner
            Dec 23 '14 at 6:11











          • Yes, It won't move the .files

            – Anwar
            Dec 24 '14 at 18:11






          • 3





            Nb. your -print0 | xargs -0 mv -t ~/Videos can be more efficiently done with -exec mv -t ~/Videos {} + :-)

            – artfulrobot
            Jun 9 '15 at 13:46






          • 1





            mv -v ~/Downloads/* ~/Videos/ does not work for hidden files

            – FreeLightman
            Mar 18 '18 at 15:20














          261












          261








          261







          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:



          If you are interested in moving 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















          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:



          If you are interested in moving 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














          share|improve this answer



          share|improve this answer








          edited May 11 '17 at 4:53









          Zanna

          50.4k13133241




          50.4k13133241










          answered Aug 6 '12 at 15:18









          AnwarAnwar

          56k22145253




          56k22145253








          • 3





            you can use mv alone to move an entire directory to another folder: mv folder ~/Documents

            – JohnMerlino
            Aug 9 '14 at 22:42






          • 14





            FYI I believe your first command ("mv -v ~/Downloads/* ~/Videos/") won't move dot files.

            – Mark Doliner
            Dec 23 '14 at 6:11











          • Yes, It won't move the .files

            – Anwar
            Dec 24 '14 at 18:11






          • 3





            Nb. your -print0 | xargs -0 mv -t ~/Videos can be more efficiently done with -exec mv -t ~/Videos {} + :-)

            – artfulrobot
            Jun 9 '15 at 13:46






          • 1





            mv -v ~/Downloads/* ~/Videos/ does not work for hidden files

            – FreeLightman
            Mar 18 '18 at 15:20














          • 3





            you can use mv alone to move an entire directory to another folder: mv folder ~/Documents

            – JohnMerlino
            Aug 9 '14 at 22:42






          • 14





            FYI I believe your first command ("mv -v ~/Downloads/* ~/Videos/") won't move dot files.

            – Mark Doliner
            Dec 23 '14 at 6:11











          • Yes, It won't move the .files

            – Anwar
            Dec 24 '14 at 18:11






          • 3





            Nb. your -print0 | xargs -0 mv -t ~/Videos can be more efficiently done with -exec mv -t ~/Videos {} + :-)

            – artfulrobot
            Jun 9 '15 at 13:46






          • 1





            mv -v ~/Downloads/* ~/Videos/ does not work for hidden files

            – FreeLightman
            Mar 18 '18 at 15:20








          3




          3





          you can use mv alone to move an entire directory to another folder: mv folder ~/Documents

          – JohnMerlino
          Aug 9 '14 at 22:42





          you can use mv alone to move an entire directory to another folder: mv folder ~/Documents

          – JohnMerlino
          Aug 9 '14 at 22:42




          14




          14





          FYI I believe your first command ("mv -v ~/Downloads/* ~/Videos/") won't move dot files.

          – Mark Doliner
          Dec 23 '14 at 6:11





          FYI I believe your first command ("mv -v ~/Downloads/* ~/Videos/") won't move dot files.

          – Mark Doliner
          Dec 23 '14 at 6:11













          Yes, It won't move the .files

          – Anwar
          Dec 24 '14 at 18:11





          Yes, It won't move the .files

          – Anwar
          Dec 24 '14 at 18:11




          3




          3





          Nb. your -print0 | xargs -0 mv -t ~/Videos can be more efficiently done with -exec mv -t ~/Videos {} + :-)

          – artfulrobot
          Jun 9 '15 at 13:46





          Nb. your -print0 | xargs -0 mv -t ~/Videos can be more efficiently done with -exec mv -t ~/Videos {} + :-)

          – artfulrobot
          Jun 9 '15 at 13:46




          1




          1





          mv -v ~/Downloads/* ~/Videos/ does not work for hidden files

          – FreeLightman
          Mar 18 '18 at 15:20





          mv -v ~/Downloads/* ~/Videos/ does not work for hidden files

          – FreeLightman
          Mar 18 '18 at 15:20













          19














          mv ~/Downloads/* ~/Videos


          It will move all the files including subfolders in the directory you want to mv. If you want to cp (copy) or rm (remove) you will need the -r (recursive) option to include subfolders.






          share|improve this answer





















          • 2





            My mv command doesn't have a -R option (Ubuntu 14.04).

            – Mark Doliner
            Dec 23 '14 at 6:10











          • @MarkDoliner, yes, mv doesn't need recursive option to include subfolders. One can use it also for renaming.

            – AliNâ
            Jan 25 '15 at 23:26











          • I didn't need * . Same thing happened without using the star.

            – MycrofD
            Mar 22 '17 at 13:28











          • The ~/ in the prefix of the folder names doesn't always work (doesn't work on bash and git atleast)

            – Krish Munot
            Jun 6 '17 at 23:00











          • This solution will give an error if the source directory is empty.

            – Pierre Thibault
            Jul 26 '18 at 13:04
















          19














          mv ~/Downloads/* ~/Videos


          It will move all the files including subfolders in the directory you want to mv. If you want to cp (copy) or rm (remove) you will need the -r (recursive) option to include subfolders.






          share|improve this answer





















          • 2





            My mv command doesn't have a -R option (Ubuntu 14.04).

            – Mark Doliner
            Dec 23 '14 at 6:10











          • @MarkDoliner, yes, mv doesn't need recursive option to include subfolders. One can use it also for renaming.

            – AliNâ
            Jan 25 '15 at 23:26











          • I didn't need * . Same thing happened without using the star.

            – MycrofD
            Mar 22 '17 at 13:28











          • The ~/ in the prefix of the folder names doesn't always work (doesn't work on bash and git atleast)

            – Krish Munot
            Jun 6 '17 at 23:00











          • This solution will give an error if the source directory is empty.

            – Pierre Thibault
            Jul 26 '18 at 13:04














          19












          19








          19







          mv ~/Downloads/* ~/Videos


          It will move all the files including subfolders in the directory you want to mv. If you want to cp (copy) or rm (remove) you will need the -r (recursive) option to include subfolders.






          share|improve this answer















          mv ~/Downloads/* ~/Videos


          It will move all the files including subfolders in the directory you want to mv. If you want to cp (copy) or rm (remove) you will need the -r (recursive) option to include subfolders.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 25 '15 at 23:28









          AliNâ

          4,29032035




          4,29032035










          answered Dec 8 '13 at 3:24









          user223289user223289

          19912




          19912








          • 2





            My mv command doesn't have a -R option (Ubuntu 14.04).

            – Mark Doliner
            Dec 23 '14 at 6:10











          • @MarkDoliner, yes, mv doesn't need recursive option to include subfolders. One can use it also for renaming.

            – AliNâ
            Jan 25 '15 at 23:26











          • I didn't need * . Same thing happened without using the star.

            – MycrofD
            Mar 22 '17 at 13:28











          • The ~/ in the prefix of the folder names doesn't always work (doesn't work on bash and git atleast)

            – Krish Munot
            Jun 6 '17 at 23:00











          • This solution will give an error if the source directory is empty.

            – Pierre Thibault
            Jul 26 '18 at 13:04














          • 2





            My mv command doesn't have a -R option (Ubuntu 14.04).

            – Mark Doliner
            Dec 23 '14 at 6:10











          • @MarkDoliner, yes, mv doesn't need recursive option to include subfolders. One can use it also for renaming.

            – AliNâ
            Jan 25 '15 at 23:26











          • I didn't need * . Same thing happened without using the star.

            – MycrofD
            Mar 22 '17 at 13:28











          • The ~/ in the prefix of the folder names doesn't always work (doesn't work on bash and git atleast)

            – Krish Munot
            Jun 6 '17 at 23:00











          • This solution will give an error if the source directory is empty.

            – Pierre Thibault
            Jul 26 '18 at 13:04








          2




          2





          My mv command doesn't have a -R option (Ubuntu 14.04).

          – Mark Doliner
          Dec 23 '14 at 6:10





          My mv command doesn't have a -R option (Ubuntu 14.04).

          – Mark Doliner
          Dec 23 '14 at 6:10













          @MarkDoliner, yes, mv doesn't need recursive option to include subfolders. One can use it also for renaming.

          – AliNâ
          Jan 25 '15 at 23:26





          @MarkDoliner, yes, mv doesn't need recursive option to include subfolders. One can use it also for renaming.

          – AliNâ
          Jan 25 '15 at 23:26













          I didn't need * . Same thing happened without using the star.

          – MycrofD
          Mar 22 '17 at 13:28





          I didn't need * . Same thing happened without using the star.

          – MycrofD
          Mar 22 '17 at 13:28













          The ~/ in the prefix of the folder names doesn't always work (doesn't work on bash and git atleast)

          – Krish Munot
          Jun 6 '17 at 23:00





          The ~/ in the prefix of the folder names doesn't always work (doesn't work on bash and git atleast)

          – Krish Munot
          Jun 6 '17 at 23:00













          This solution will give an error if the source directory is empty.

          – Pierre Thibault
          Jul 26 '18 at 13:04





          This solution will give an error if the source directory is empty.

          – Pierre Thibault
          Jul 26 '18 at 13:04











          6














          It's possible by using rsync, for example:



          rsync -vau --remove-source-files src/ dst/


          where:




          -v, --verbose: Increase verbosity.



          -a, --archive: Archive mode; equals -rlptgoD (no -H, -A, -X).



          -u, --update: Skip files that are newer on the receiver.



          --remove-source-files This tells rsync to remove from the sending side the files (meaning non-directories) that are a part of the transfer and have been successfully duplicated on the receiving side.




          If you've root privileges, prefix with sudo to override potential permission issues.






          share|improve this answer





















          • 1





            WARNING! the --delete-after option as noted doesn't work the way you might expect. It doesn't delete the source files after successful copy... IT DELETES ALL THE REMAINING/OTHER FILES IN THE DESTINATION. (as @kenorb noted... but I didn't read carefully enough! DOH)

            – Jay Marm
            Aug 10 '18 at 4:06


















          6














          It's possible by using rsync, for example:



          rsync -vau --remove-source-files src/ dst/


          where:




          -v, --verbose: Increase verbosity.



          -a, --archive: Archive mode; equals -rlptgoD (no -H, -A, -X).



          -u, --update: Skip files that are newer on the receiver.



          --remove-source-files This tells rsync to remove from the sending side the files (meaning non-directories) that are a part of the transfer and have been successfully duplicated on the receiving side.




          If you've root privileges, prefix with sudo to override potential permission issues.






          share|improve this answer





















          • 1





            WARNING! the --delete-after option as noted doesn't work the way you might expect. It doesn't delete the source files after successful copy... IT DELETES ALL THE REMAINING/OTHER FILES IN THE DESTINATION. (as @kenorb noted... but I didn't read carefully enough! DOH)

            – Jay Marm
            Aug 10 '18 at 4:06
















          6












          6








          6







          It's possible by using rsync, for example:



          rsync -vau --remove-source-files src/ dst/


          where:




          -v, --verbose: Increase verbosity.



          -a, --archive: Archive mode; equals -rlptgoD (no -H, -A, -X).



          -u, --update: Skip files that are newer on the receiver.



          --remove-source-files This tells rsync to remove from the sending side the files (meaning non-directories) that are a part of the transfer and have been successfully duplicated on the receiving side.




          If you've root privileges, prefix with sudo to override potential permission issues.






          share|improve this answer















          It's possible by using rsync, for example:



          rsync -vau --remove-source-files src/ dst/


          where:




          -v, --verbose: Increase verbosity.



          -a, --archive: Archive mode; equals -rlptgoD (no -H, -A, -X).



          -u, --update: Skip files that are newer on the receiver.



          --remove-source-files This tells rsync to remove from the sending side the files (meaning non-directories) that are a part of the transfer and have been successfully duplicated on the receiving side.




          If you've root privileges, prefix with sudo to override potential permission issues.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Aug 10 '18 at 21:48

























          answered Jun 6 '15 at 15:08









          kenorbkenorb

          4,28613752




          4,28613752








          • 1





            WARNING! the --delete-after option as noted doesn't work the way you might expect. It doesn't delete the source files after successful copy... IT DELETES ALL THE REMAINING/OTHER FILES IN THE DESTINATION. (as @kenorb noted... but I didn't read carefully enough! DOH)

            – Jay Marm
            Aug 10 '18 at 4:06
















          • 1





            WARNING! the --delete-after option as noted doesn't work the way you might expect. It doesn't delete the source files after successful copy... IT DELETES ALL THE REMAINING/OTHER FILES IN THE DESTINATION. (as @kenorb noted... but I didn't read carefully enough! DOH)

            – Jay Marm
            Aug 10 '18 at 4:06










          1




          1





          WARNING! the --delete-after option as noted doesn't work the way you might expect. It doesn't delete the source files after successful copy... IT DELETES ALL THE REMAINING/OTHER FILES IN THE DESTINATION. (as @kenorb noted... but I didn't read carefully enough! DOH)

          – Jay Marm
          Aug 10 '18 at 4:06







          WARNING! the --delete-after option as noted doesn't work the way you might expect. It doesn't delete the source files after successful copy... IT DELETES ALL THE REMAINING/OTHER FILES IN THE DESTINATION. (as @kenorb noted... but I didn't read carefully enough! DOH)

          – Jay Marm
          Aug 10 '18 at 4:06













          3














          Use



          mv -v ~/rootfolder/branch/* ~/rootfolder


          I hope this helps. Because I had the same pain and wasted a lot of time fixing my mistake.






          share|improve this answer




























            3














            Use



            mv -v ~/rootfolder/branch/* ~/rootfolder


            I hope this helps. Because I had the same pain and wasted a lot of time fixing my mistake.






            share|improve this answer


























              3












              3








              3







              Use



              mv -v ~/rootfolder/branch/* ~/rootfolder


              I hope this helps. Because I had the same pain and wasted a lot of time fixing my mistake.






              share|improve this answer













              Use



              mv -v ~/rootfolder/branch/* ~/rootfolder


              I hope this helps. Because I had the same pain and wasted a lot of time fixing my mistake.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Jan 25 '15 at 23:06









              Udit ChughUdit Chugh

              364




              364























                  3














                  For the simple case:



                  mv ~/Downloads/* ~/Videos


                  If you want to move dot files too, then set the dotglob shell option.



                  shopt -s dotglob
                  mv ~/Downloads/* ~/Videos


                  This leaves the shell option set.



                  For one time dotglob use, run the commands in a subshell:



                  (shopt -s dotglob; mv ~/Downloads/* ~/Videos)





                  share|improve this answer




























                    3














                    For the simple case:



                    mv ~/Downloads/* ~/Videos


                    If you want to move dot files too, then set the dotglob shell option.



                    shopt -s dotglob
                    mv ~/Downloads/* ~/Videos


                    This leaves the shell option set.



                    For one time dotglob use, run the commands in a subshell:



                    (shopt -s dotglob; mv ~/Downloads/* ~/Videos)





                    share|improve this answer


























                      3












                      3








                      3







                      For the simple case:



                      mv ~/Downloads/* ~/Videos


                      If you want to move dot files too, then set the dotglob shell option.



                      shopt -s dotglob
                      mv ~/Downloads/* ~/Videos


                      This leaves the shell option set.



                      For one time dotglob use, run the commands in a subshell:



                      (shopt -s dotglob; mv ~/Downloads/* ~/Videos)





                      share|improve this answer













                      For the simple case:



                      mv ~/Downloads/* ~/Videos


                      If you want to move dot files too, then set the dotglob shell option.



                      shopt -s dotglob
                      mv ~/Downloads/* ~/Videos


                      This leaves the shell option set.



                      For one time dotglob use, run the commands in a subshell:



                      (shopt -s dotglob; mv ~/Downloads/* ~/Videos)






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Jan 22 '18 at 10:16









                      Hontvári LeventeHontvári Levente

                      45839




                      45839























                          1















                          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





















                          • 3





                            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


















                          1















                          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





















                          • 3





                            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
















                          1












                          1








                          1








                          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
















                          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














                          share|improve this answer



                          share|improve this answer








                          edited Sep 12 '13 at 12:56









                          Braiam

                          51.5k20136220




                          51.5k20136220










                          answered Sep 12 '13 at 12:07









                          jrhjrh

                          192




                          192








                          • 3





                            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
















                          • 3





                            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










                          3




                          3





                          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







                          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













                          0














                          To move a directory with or without content to its new name just like how you would use the mv command to rename a file:



                          mv -T dir1 dir2



                          where:





                          • -T treats the destination as a normal file


                          • dir1 is the original name of the directory


                          • dir2 is the new name of the directory


                          NB: dir2 doesn't have to exist.



                          I hope this saves someone a lot of time, as a noob, before this, I would create a directory with the new name and then move the contents of the directory to the directory created earlier.



                          Use for subdirectories



                          This command is useful when many files have been saved in a subfolder of the target directory i.e. Downloads/mp4. In this example, running mv -T Downloads/mp4 Videos will result in mp4 subfolder being removed and all files contained inside are moved to Videos folder.






                          share|improve this answer





















                          • 1





                            +1 because tested working in Xubuntu 14.04. I have added an example in this answer to show that this command will cause the dir1 to be removed. Aside from this precaution, this answer has noted something good for daily use.

                            – clearkimura
                            Dec 9 '15 at 8:45






                          • 1





                            "To move a directory with or without content to its new name" How can you move a directory...to a name? That makes no sense. "-T treats the destination as a normal file" How can a destination be a file? Do you mean directory?

                            – Monica Heddneck
                            Apr 29 '17 at 23:55











                          • Its like renaming a file to its new name like you would do with something like mv fileA fileB but the -T flag in this case treats the destination/directory as a file and renames it.

                            – Feyisayo Sonubi
                            Apr 30 '17 at 22:10
















                          0














                          To move a directory with or without content to its new name just like how you would use the mv command to rename a file:



                          mv -T dir1 dir2



                          where:





                          • -T treats the destination as a normal file


                          • dir1 is the original name of the directory


                          • dir2 is the new name of the directory


                          NB: dir2 doesn't have to exist.



                          I hope this saves someone a lot of time, as a noob, before this, I would create a directory with the new name and then move the contents of the directory to the directory created earlier.



                          Use for subdirectories



                          This command is useful when many files have been saved in a subfolder of the target directory i.e. Downloads/mp4. In this example, running mv -T Downloads/mp4 Videos will result in mp4 subfolder being removed and all files contained inside are moved to Videos folder.






                          share|improve this answer





















                          • 1





                            +1 because tested working in Xubuntu 14.04. I have added an example in this answer to show that this command will cause the dir1 to be removed. Aside from this precaution, this answer has noted something good for daily use.

                            – clearkimura
                            Dec 9 '15 at 8:45






                          • 1





                            "To move a directory with or without content to its new name" How can you move a directory...to a name? That makes no sense. "-T treats the destination as a normal file" How can a destination be a file? Do you mean directory?

                            – Monica Heddneck
                            Apr 29 '17 at 23:55











                          • Its like renaming a file to its new name like you would do with something like mv fileA fileB but the -T flag in this case treats the destination/directory as a file and renames it.

                            – Feyisayo Sonubi
                            Apr 30 '17 at 22:10














                          0












                          0








                          0







                          To move a directory with or without content to its new name just like how you would use the mv command to rename a file:



                          mv -T dir1 dir2



                          where:





                          • -T treats the destination as a normal file


                          • dir1 is the original name of the directory


                          • dir2 is the new name of the directory


                          NB: dir2 doesn't have to exist.



                          I hope this saves someone a lot of time, as a noob, before this, I would create a directory with the new name and then move the contents of the directory to the directory created earlier.



                          Use for subdirectories



                          This command is useful when many files have been saved in a subfolder of the target directory i.e. Downloads/mp4. In this example, running mv -T Downloads/mp4 Videos will result in mp4 subfolder being removed and all files contained inside are moved to Videos folder.






                          share|improve this answer















                          To move a directory with or without content to its new name just like how you would use the mv command to rename a file:



                          mv -T dir1 dir2



                          where:





                          • -T treats the destination as a normal file


                          • dir1 is the original name of the directory


                          • dir2 is the new name of the directory


                          NB: dir2 doesn't have to exist.



                          I hope this saves someone a lot of time, as a noob, before this, I would create a directory with the new name and then move the contents of the directory to the directory created earlier.



                          Use for subdirectories



                          This command is useful when many files have been saved in a subfolder of the target directory i.e. Downloads/mp4. In this example, running mv -T Downloads/mp4 Videos will result in mp4 subfolder being removed and all files contained inside are moved to Videos folder.







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Dec 9 '15 at 8:42









                          clearkimura

                          3,83911954




                          3,83911954










                          answered Dec 9 '15 at 7:33









                          Feyisayo SonubiFeyisayo Sonubi

                          1731211




                          1731211








                          • 1





                            +1 because tested working in Xubuntu 14.04. I have added an example in this answer to show that this command will cause the dir1 to be removed. Aside from this precaution, this answer has noted something good for daily use.

                            – clearkimura
                            Dec 9 '15 at 8:45






                          • 1





                            "To move a directory with or without content to its new name" How can you move a directory...to a name? That makes no sense. "-T treats the destination as a normal file" How can a destination be a file? Do you mean directory?

                            – Monica Heddneck
                            Apr 29 '17 at 23:55











                          • Its like renaming a file to its new name like you would do with something like mv fileA fileB but the -T flag in this case treats the destination/directory as a file and renames it.

                            – Feyisayo Sonubi
                            Apr 30 '17 at 22:10














                          • 1





                            +1 because tested working in Xubuntu 14.04. I have added an example in this answer to show that this command will cause the dir1 to be removed. Aside from this precaution, this answer has noted something good for daily use.

                            – clearkimura
                            Dec 9 '15 at 8:45






                          • 1





                            "To move a directory with or without content to its new name" How can you move a directory...to a name? That makes no sense. "-T treats the destination as a normal file" How can a destination be a file? Do you mean directory?

                            – Monica Heddneck
                            Apr 29 '17 at 23:55











                          • Its like renaming a file to its new name like you would do with something like mv fileA fileB but the -T flag in this case treats the destination/directory as a file and renames it.

                            – Feyisayo Sonubi
                            Apr 30 '17 at 22:10








                          1




                          1





                          +1 because tested working in Xubuntu 14.04. I have added an example in this answer to show that this command will cause the dir1 to be removed. Aside from this precaution, this answer has noted something good for daily use.

                          – clearkimura
                          Dec 9 '15 at 8:45





                          +1 because tested working in Xubuntu 14.04. I have added an example in this answer to show that this command will cause the dir1 to be removed. Aside from this precaution, this answer has noted something good for daily use.

                          – clearkimura
                          Dec 9 '15 at 8:45




                          1




                          1





                          "To move a directory with or without content to its new name" How can you move a directory...to a name? That makes no sense. "-T treats the destination as a normal file" How can a destination be a file? Do you mean directory?

                          – Monica Heddneck
                          Apr 29 '17 at 23:55





                          "To move a directory with or without content to its new name" How can you move a directory...to a name? That makes no sense. "-T treats the destination as a normal file" How can a destination be a file? Do you mean directory?

                          – Monica Heddneck
                          Apr 29 '17 at 23:55













                          Its like renaming a file to its new name like you would do with something like mv fileA fileB but the -T flag in this case treats the destination/directory as a file and renames it.

                          – Feyisayo Sonubi
                          Apr 30 '17 at 22:10





                          Its like renaming a file to its new name like you would do with something like mv fileA fileB but the -T flag in this case treats the destination/directory as a file and renames it.

                          – Feyisayo Sonubi
                          Apr 30 '17 at 22:10











                          0














                          try it



                          find ~/Desktop -type f -iname  "*.mp4" -exec mv {} ~/Videos ;


                          -type
                          with the argument -type you can specify type file.on this statement that is the mean file.if using of -d that means directory.



                          -iname:
                          the most common and obvious method to look for a file is using its -name argument.if you are not sure about its case-sensitivity you can use of -iname argument



                          mv {}
                          and finally to specify target directory and then moving the files on there using mv {} argument






                          share|improve this answer




























                            0














                            try it



                            find ~/Desktop -type f -iname  "*.mp4" -exec mv {} ~/Videos ;


                            -type
                            with the argument -type you can specify type file.on this statement that is the mean file.if using of -d that means directory.



                            -iname:
                            the most common and obvious method to look for a file is using its -name argument.if you are not sure about its case-sensitivity you can use of -iname argument



                            mv {}
                            and finally to specify target directory and then moving the files on there using mv {} argument






                            share|improve this answer


























                              0












                              0








                              0







                              try it



                              find ~/Desktop -type f -iname  "*.mp4" -exec mv {} ~/Videos ;


                              -type
                              with the argument -type you can specify type file.on this statement that is the mean file.if using of -d that means directory.



                              -iname:
                              the most common and obvious method to look for a file is using its -name argument.if you are not sure about its case-sensitivity you can use of -iname argument



                              mv {}
                              and finally to specify target directory and then moving the files on there using mv {} argument






                              share|improve this answer













                              try it



                              find ~/Desktop -type f -iname  "*.mp4" -exec mv {} ~/Videos ;


                              -type
                              with the argument -type you can specify type file.on this statement that is the mean file.if using of -d that means directory.



                              -iname:
                              the most common and obvious method to look for a file is using its -name argument.if you are not sure about its case-sensitivity you can use of -iname argument



                              mv {}
                              and finally to specify target directory and then moving the files on there using mv {} argument







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Apr 1 '18 at 16:54









                              pedram shabanipedram shabani

                              1085




                              1085























                                  0














                                  mv source_path/* destination_path/


                                  here you have to put forward slash and * after source path so that it will take files inside source_path instead of the complete source directory.



                                  Example: mv /home/username/test/* /home/username/test2/



                                  The above command moves all files (unless they are hidden) in the source directory to the destination directory.






                                  share|improve this answer










                                  New contributor




                                  vivek Kumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                  Check out our Code of Conduct.

























                                    0














                                    mv source_path/* destination_path/


                                    here you have to put forward slash and * after source path so that it will take files inside source_path instead of the complete source directory.



                                    Example: mv /home/username/test/* /home/username/test2/



                                    The above command moves all files (unless they are hidden) in the source directory to the destination directory.






                                    share|improve this answer










                                    New contributor




                                    vivek Kumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.























                                      0












                                      0








                                      0







                                      mv source_path/* destination_path/


                                      here you have to put forward slash and * after source path so that it will take files inside source_path instead of the complete source directory.



                                      Example: mv /home/username/test/* /home/username/test2/



                                      The above command moves all files (unless they are hidden) in the source directory to the destination directory.






                                      share|improve this answer










                                      New contributor




                                      vivek Kumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                      Check out our Code of Conduct.










                                      mv source_path/* destination_path/


                                      here you have to put forward slash and * after source path so that it will take files inside source_path instead of the complete source directory.



                                      Example: mv /home/username/test/* /home/username/test2/



                                      The above command moves all files (unless they are hidden) in the source directory to the destination directory.







                                      share|improve this answer










                                      New contributor




                                      vivek Kumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                      Check out our Code of Conduct.









                                      share|improve this answer



                                      share|improve this answer








                                      edited Jan 10 at 18:18









                                      Zanna

                                      50.4k13133241




                                      50.4k13133241






                                      New contributor




                                      vivek Kumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                      Check out our Code of Conduct.









                                      answered Jan 10 at 14:58









                                      vivek Kumarvivek Kumar

                                      11




                                      11




                                      New contributor




                                      vivek Kumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                      Check out our Code of Conduct.





                                      New contributor





                                      vivek Kumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                      Check out our Code of Conduct.






                                      vivek Kumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                      Check out our Code of Conduct.






























                                          draft saved

                                          draft discarded




















































                                          Thanks for contributing an answer to Ask Ubuntu!


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.




                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function () {
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f172629%2fhow-do-i-move-all-files-from-one-folder-to-another-using-the-command-line%23new-answer', 'question_page');
                                          }
                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          數位音樂下載

                                          When can things happen in Etherscan, such as the picture below?

                                          格利澤436b