windows 尝试使用批处理将文件从当前目录复制到另一个目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23781347/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Trying to copy files from current directory to another with batch
提问by Mattyy123
I have a folder on my desktop called 'Folder' and inside this folder, there is another folder called 'Internal Folder'. Inside 'Internal Folder' there is a file called 'abc.txt', and inside 'Folder', I have a batch file to copy the contents of 'Internal Folder' to another destination on the computer.
我的桌面上有一个名为“文件夹”的文件夹,在此文件夹中,还有另一个文件夹名为“内部文件夹”。在“内部文件夹”中有一个名为“abc.txt”的文件,在“文件夹”中,我有一个批处理文件可以将“内部文件夹”的内容复制到计算机上的另一个目的地。
Now, I assumed that because you can run a file using start /d "\" file.exe
("\" being the directory that the batch file is housed) that I could use xcopy in a like fashion..
现在,我假设因为您可以使用start /d "\" file.exe
(“\”是批处理文件所在的目录)运行文件,所以我可以以类似的方式使用 xcopy..
xcopy "\Internal Folder\abc.txt" "C:\Users\Matthew"
(As an example.)
xcopy "\Internal Folder\abc.txt" "C:\Users\Matthew"
(举个例子。)
So my question is, what command can I use to copy over a file from a folder that can be moved around to different places on the hard drive, to a static directory?
所以我的问题是,我可以使用什么命令将文件从可以移动到硬盘驱动器上不同位置的文件夹复制到静态目录?
Thanks in advance.
提前致谢。
回答by foxidrive
If you use relative paths, this will copy the file from "Internal Folder" which resides in the current directory.
如果您使用相对路径,这将从驻留在当前目录中的“内部文件夹”中复制文件。
xcopy "Internal Folder\abc.txt" "C:\Users\Matthew"
In Linux the syntax is ./foldername
but in Windows the .
is implied, which means current directory, but you can add it too as shown here:
在 Linux 中,语法是./foldername
但在 Windows 中.
是隐含的,这意味着当前目录,但您也可以添加它,如下所示:
xcopy ".\Internal Folder\abc.txt" "C:\Users\Matthew"
回答by PodTech.io
if you dont want to specify the folder, you can use this;
如果你不想指定文件夹,你可以使用这个;
xcopy /y /s ".\*" %TEMPDIR%