2011-01-20 222 views

回答

43

你可以使用move。從help move文檔狀態:

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. 

請參見下面的談話爲例它最初顯示的qq1qq2目錄具有三個沒有文件分別。然後,我們執行move,我們發現這三個文件已按預期從qq1移至qq2

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

這非常有幫助,我最終從本指南學到了很多東西。謝謝。它爲我節省了很多時間。 – Chirag 2011-01-20 23:54:34

4

查找move /?在Windows和man mv在Unix系統

+0

這是一臺windows機器 – Chirag 2011-01-20 03:18:49

+1

`move --help`?在Windows上?真?你嘗試過嗎? :-)我認爲你的意思是「移動/?」或「幫助移動」。 – paxdiablo 2011-01-20 03:33:08

+0

在Windows上,`move --help`會導致`系統找不到指定的文件.`。 – aphoria 2011-01-20 14:08:07

3

您可以使用命令move

move <source directory> <destination directory> 

Reference

13

此命令將所有文件移動在originalfolder到destinationfolder。

MOVE c:\originalfolder\* c:\destinationfolder 

(但它不會移動任何子文件夾到新的位置)

要查找的指示MOVE命令類型這在Windows命令提示符:

MOVE /? 
26
move c:\sourcefolder c:\targetfolder 

將工作,但你最終會像這樣的結構:

c:\targetfolder\sourcefolder\[all the subfolders & files] 

如果要移動只是一個文件夾到另一個內容,那麼這應該這樣做:

SET src_folder=c:\srcfold 
SET tar_folder=c:\tarfold 

for /f %%a IN ('dir "%src_folder%" /b') do move %src_folder%\%%a %tar_folder% 

pause 
2

使用move 然後move <file or folder> <destination directory>

-1

要移動子目錄,包括空文件夾,你可以使用複製和刪除的組合:

# Setting up test env... 
C:\> mkdir folder1 folder1\sub1 folder1\sub2 folder2 
C:\> touch folder1\sub1\file.txt 

# Copy "folder1" to "folder2", then remove "folder1" 
C:\> xcopy /e folder1 folder2 
C:\> rmdir /s /q folder1 
1

robocopy似乎是最通用的。看到它的其他選項在幫助中

robocopy /? 
robocopy SRC DST /E /MOV 
相關問題