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

前端 未结 9 1242
北恋
北恋 2020-12-01 02:53

What is the best command to move all files from one folder to another?

I want to do this from within a batch file.

相关标签:
9条回答
  • 2020-12-01 03:04

    Lookup move /? on Windows and man mv on Unix systems

    0 讨论(0)
  • 2020-12-01 03:05

    robocopy seems to be the most versatile. See it's other options in the help

    robocopy /?
    robocopy SRC DST /E /MOV
    
    0 讨论(0)
  • 2020-12-01 03:17

    OMG I Got A Quick File Move Command form CMD

    1)Command will move All Files and Sub Folders into another location in 1 second .

    check command

    C:\user>move "your source path " "your destination path" 
    

    Hint : For move all Files and Sub folders

    C:\user>move "f:\wamp\www" "f:\wapm_3.2\www\old Projects"
    

    check image

    you can see that it's before i try some other code that was not working due to more than 1 files and folder was there. when i try to execute code that is under line by red color then all folder move in 1 second.

    now check this image. here Total 6.7GB data moved in 1 second... you can check date of post and move as well as Folder name.

    i will soon make a windows app that will do same..

    0 讨论(0)
  • 2020-12-01 03:19

    You can use move for this. The documentation from help move states:

    Moves files and renames files and directories.
    
    To move one or more files:
    MOVE [/Y | /-Y] [drive:][path]filename1[,...] destination
    
    To rename a directory:
    MOVE [/Y | /-Y] [drive:][path]dirname1 dirname2
    
      [drive:][path]filename1 Specifies the location and name of the file
                              or files you want to move.
      destination             Specifies the new location of the file. Destination
                              can consist of a drive letter and colon, a
                              directory name, or a combination. If you are moving
                              only one file, you can also include a filename if
                              you want to rename the file when you move it.
      [drive:][path]dirname1  Specifies the directory you want to rename.
      dirname2                Specifies the new name of the directory.
    
      /Y                      Suppresses prompting to confirm you want to
                              overwrite an existing destination file.
      /-Y                     Causes prompting to confirm you want to overwrite
                              an existing destination file.
    
    The switch /Y may be present in the COPYCMD environment variable.
    This may be overridden with /-Y on the command line.  Default is
    to prompt on overwrites unless MOVE command is being executed from
    within a batch script.
    

    See the following transcript for an example where it initially shows the qq1 and qq2 directories as having three and no files respectively. Then, we do the move and we find that the three files have been moved from qq1 to qq2 as expected.

    C:\Documents and Settings\Pax\My Documents>dir qq1
     Volume in drive C is Primary
     Volume Serial Number is 04F7-0E7B
    
     Directory of C:\Documents and Settings\Pax\My Documents\qq1
    
    20/01/2011  11:36 AM    <DIR>          .
    20/01/2011  11:36 AM    <DIR>          ..
    20/01/2011  11:36 AM                13 xx1
    20/01/2011  11:36 AM                13 xx2
    20/01/2011  11:36 AM                13 xx3
                   3 File(s)             39 bytes
                   2 Dir(s)  20,092,547,072 bytes free
    
    C:\Documents and Settings\Pax\My Documents>dir qq2
     Volume in drive C is Primary
     Volume Serial Number is 04F7-0E7B
    
     Directory of C:\Documents and Settings\Pax\My Documents\qq2
    
    20/01/2011  11:36 AM    <DIR>          .
    20/01/2011  11:36 AM    <DIR>          ..
                   0 File(s)              0 bytes
                   2 Dir(s)  20,092,547,072 bytes free
    

     

    C:\Documents and Settings\Pax\My Documents>move qq1\* qq2
    C:\Documents and Settings\Pax\My Documents\qq1\xx1
    C:\Documents and Settings\Pax\My Documents\qq1\xx2
    C:\Documents and Settings\Pax\My Documents\qq1\xx3
    

     

    C:\Documents and Settings\Pax\My Documents>dir qq1
     Volume in drive C is Primary
     Volume Serial Number is 04F7-0E7B
    
     Directory of C:\Documents and Settings\Pax\My Documents\qq1
    
    20/01/2011  11:37 AM    <DIR>          .
    20/01/2011  11:37 AM    <DIR>          ..
                   0 File(s)              0 bytes
                   2 Dir(s)  20,092,547,072 bytes free
    
    C:\Documents and Settings\Pax\My Documents>dir qq2
     Volume in drive C is Primary
     Volume Serial Number is 04F7-0E7B
    
     Directory of C:\Documents and Settings\Pax\My Documents\qq2
    
    20/01/2011  11:37 AM    <DIR>          .
    20/01/2011  11:37 AM    <DIR>          ..
    20/01/2011  11:36 AM                13 xx1
    20/01/2011  11:36 AM                13 xx2
    20/01/2011  11:36 AM                13 xx3
                   3 File(s)             39 bytes
                   2 Dir(s)  20,092,547,072 bytes free
    
    0 讨论(0)
  • 2020-12-01 03:19

    use move then move <file or folder> <destination directory>

    0 讨论(0)
  • 2020-12-01 03:21

    Be sure to use quotes if there are spaces in the file path:

    move "C:\Users\MyName\My Old Folder\*" "C:\Users\MyName\My New Folder"
    

    That will move the contents of C:\Users\MyName\My Old Folder\ to C:\Users\MyName\My New Folder

    0 讨论(0)
提交回复
热议问题