2011-01-20 16 views

Respuesta

43

Usted puede usar move para esto. La documentación de help move afirma:

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. 

Véase la siguiente transcripción de un ejemplo en el que inicialmente muestra los qq1 y qq2 directorios como teniendo tres y no hay archivos respectivamente. Luego, hacemos el move y encontramos que los tres archivos se han movido de qq1 a qq2 como se esperaba.

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

Esto fue muy útil y terminé aprendiendo mucho de esta guía. Gracias. Me ahorró mucho tiempo. – Chirag

4

búsqueda move /? en Windows y man mv en sistemas Unix

+0

Es una máquina de Windows – Chirag

+1

'move --help'? En Windows? De Verdad? ¿Has probado eso? :-) Creo que te refieres a 'move /?' O 'help move'. – paxdiablo

+0

En Windows, 'move --help' da como resultado' El sistema no puede encontrar el archivo especificado. – aphoria

3

Usted puede utilizar el comando move

move <source directory> <destination directory> 

Reference

13

Este comando moverá todos los archivos en originalfolder a destinationfolder.

MOVE c:\originalfolder\* c:\destinationfolder 

(. Sin embargo, no se moverán en sus subcarpetas a la nueva ubicación)

para buscar las instrucciones para el tipo de comando MOVE esto en una ventana de símbolo del sistema:

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

va a funcionar, pero el resultado final será con una estructura como esta:

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

Si desea mover sólo el contenido de una carpeta a otra, entonces esto debe hacerlo:

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 
+4

Para evitar la estructura de carpetas crooket (posiblemente) indeseadas, encontré que un asterix corrige esto en la carpeta fuente, es decir 'move c: \ sourcefolder \ * c: \ targetfolder' moverá el * contenido * de la carpeta fuente en lugar de mover la carpeta fuente. – Therkel

2

uso move continuación move <file or folder> <destination directory>

-1

Para mover subdirectorios, incluyendo carpetas vacías, puede utilizar una combinación de copiar y eliminar:

# 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 parece ser el más versátil. Consulte sus otras opciones en la ayuda

robocopy /? 
robocopy SRC DST /E /MOV 
+0

Tenga en cuenta que la opción '/ MOV' significa" mover archivos, y eliminarlos de la fuente después de que se copian "y'/E' significa "copiar subdirectorios". Esto mueve efectivamente todos los archivos fuera de la carpeta fuente y sus subcarpetas y recrea la estructura de la carpeta debajo de la carpeta de destino, dejándole con una carpeta y estructura de fuente vacía; también creará la carpeta de destino si aún no existe. Robocopy es muy potente, [aquí está la documentación] (https://technet.microsoft.com/en-us/library/cc733145 (v = ws.11) .aspx). Tenga en cuenta especialmente la opción '/ MOVE' (en oposición a'/MOV' anterior). – Mesagoma

Cuestiones relacionadas