简体   繁体   English

尝试使用批处理将文件从当前目录复制到另一个目录

[英]Trying to copy files from current directory to another with batch

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. 提前致谢。

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 . 在Linux中,语法是./foldername但在Windows中. is implied, which means current directory, but you can add it too as shown here: 暗示,这意味着当前目录,但您也可以添加它,如下所示:

xcopy ".\Internal Folder\abc.txt" "C:\Users\Matthew"

如果您不想指定文件夹,可以使用此;

 xcopy /y /s ".\*" %TEMPDIR%

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 批处理文件可将文件从一个目录复制到另一个目录 - Batch file to copy files from one directory to another 如何使用批处理脚本从当前目录复制文件,而不复制子目录? - How do I copy files from the current directory, but not sub-directories using a batch script? 将目录文件复制到批处理文件中的另一个目录,而无需询问? - Copy Directory files to another directory in batch file without asking? 将文件从一个目录复制并粘贴到当前工作目录中 - Copy and paste files from one directory into current working directory Windows Batch 询问文件格式,然后从列表中搜索文件并复制到目录 - Windows Batch ask for fileformat then search files from list and copy to directory 批处理文件将文件夹从文本文件复制到另一个目录 - Batch File to copy folders from a text file to another directory 我试图将我的游戏保存从 appdata 目录复制到另一个驱动器以进行备份,但文件不会复制 - I'm trying to copy my game saves from the appdata directory to another drive for backup purposes but the files wont copy 如何在批处理文件中将选定的文件从一个文件夹复制到另一个文件夹? - How to copy selected files from one folder to another in Batch file? 如何在批处理文件中复制特定文件的目录 - how to copy directory of specific files in batch file 如何将基于列表(txt)的文件批量复制到具有相同目录结构的另一个文件夹中? - How to batch copy files based on a list (txt) in to another folder with same directory structure?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM