gpt4 book ai didi

batch-file - 如何使用命令行将所有文件从一个文件夹移动到另一个文件夹?

转载 作者:行者123 更新时间:2023-12-02 03:57:13 25 4
gpt4 key购买 nike

将所有文件从一个文件夹移动到另一个文件夹的最佳命令是什么?

我想在批处理文件中执行此操作。

最佳答案

您可以使用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

关于batch-file - 如何使用命令行将所有文件从一个文件夹移动到另一个文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4743094/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com