您的位置:首页 > 其它

入门命令11-移动文件(夹):move

2011-12-12 11:11 1006 查看
move的意思不解释了 它可以用来移动文件(夹)或者对移动文件(夹)时重命名.

C:\DOCUME~1\DOUPI>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.


用这个命令有几个注意点,来看几个例子.

1. 基本移动文件(夹),在win平台,但它不能跨驱动器移动文件夹.

E:\>md aa bb\bbb cc
E:\>copy con aa\test1.txt
this is test11111^Z
已复制         1 个文件。

rem 移动文件到文件夹
E:\>move aa\test1.txt cc\
rem 移动一个文件夹到另一文件夹,带了\,,,移动失败!??
E:\>move bb\ cc\
系统找不到指定的文件。
rem 再来一次,成功
E:\>move bb cc\

rem 跨驱动器移动文件,成功.
E:\>move cc\test1.txt d:\
E:\>dir d:\test1.txt
驱动器 D 中的卷是 SOFT
卷的序列号是 6C97-9E44
d:\ 的目录
2011-12-12  10:49                17 test1.txt
1 个文件             17 字节
0 个目录 133,784,256,512 可用字节
rem 跨驱动器移动文件夹,失败
E:\>move cc\bb d:\
拒绝访问。


2.重命名功能

rem 移动文件时进行重命名
E:\>move d:\test1.txt e:\cc\test2.txt

rem 如果第二参数为已存在的文件夹,则是移动操作
E:\>move aa cc
E:\>cd cc
E:\cc>dir
驱动器 E 中的卷是 TEST
卷的序列号是 EC10-1C79
E:\cc 的目录
2011-12-12  10:59    <DIR>          .
2011-12-12  10:59    <DIR>          ..
2011-12-12  10:50    <DIR>          aa
2011-12-12  10:49    <DIR>          bb
2011-12-12  10:49                17 test2.txt
1 个文件             17 字节
4 个目录 131,208,916,992 可用字节
rem 当第二参数为不存在的文件夹,刚是重命名文件夹操作
E:\cc>move bb cc
移动了         1 个文件。


3.其他注意

E:\cc>copy test2.txt aa\
已复制         1 个文件。
rem 移动文件时覆盖会自动提示
E:\cc>move test2.txt aa\
改写 E:\cc\aa\test2.txt 吗? (Yes/No/All): y

E:\cc>copy aa\test2.txt .
已复制         1 个文件。
rem /y参数即可去掉覆盖提示,这个与其他命令是一样的. cmd中默认为-y,bat中默认为y,这点要注意
E:\cc>move /y aa\test2.txt .

rem 对具有隐藏属性的文件(夹)无法操作
E:\cc>attrib +h test2.txt
E:\cc>move test2.txt test1.txt
系统找不到指定的文件。


OK,此篇完结.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: