简体   繁体   English

如何使用Windows批处理脚本将数据从一个文件复制到另一个文件?

[英]How to copy data from one file to another with Windows batch script?

I am a little familiar with shell scripts but not so much with Windows batch scripts. 我对Shell脚本有点熟悉,但对Windows批处理脚本却不太了解。 Need some help converting this shell script to a batch script. 需要一些帮助将此Shell脚本转换为批处理脚本。 Also how is current directory (.) like in the example below (./src/test/...) written in a batch script? 像下面的示例(./src/test / ...)中一样,当前目录(。)如何用批处理脚本编写?

In the example below, I check to see if test.xml exists. 在下面的示例中,我检查是否存在test.xml。 If it does not exist, I copy data from abc.xml to test.xml. 如果不存在,我将数据从abc.xml复制到test.xml。

 if [[ ! -f test.xml ]] ; then echo 'File "test.xml " is not there. Copying dummy file.' cp ./src/test/abc.xml test.xml fi 

You can use if not exist and copy . 您可以使用if not exist copy You specify the current directory the same way, using the backslash instead of the forward slash as directory separator, or just start your reference there without using a backslash at all. 您可以以相同的方式指定当前目录,使用反斜杠代替正斜杠作为目录分隔符,或者仅在此处开始引用而根本不使用反斜杠。

if not exist test.xml copy .\src\test\abc.xml .\test.xml

or 要么

if not exist test.xml copy src\test\abc.xml .\test.xml

暂无
暂无

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

相关问题 如何在批处理脚本中将特定数据从一个文件复制到另一个文件 - How to copy particular data from one file to another in a batch script 将数据从一个文件复制到另一个文件不起作用(批处理脚本) - Copy data From one file to another file doesn't work (Batch Script) 如何使用 windows 批处理文件或 vbs 脚本一次将多个文件 1 从 2 个文件夹复制到另一个文件夹 - How could i copy multiple files 1 at a time from 2 folders to another folder with a windows batch file or vbs script Windows批处理将一种XML复制到另一种XML - Copy from one XML to another by Windows batch 如何使用BATCH脚本将文件从一个驱动器上的文件夹复制到另一个驱动器上的同名文件夹? - How can I copy a file with a BATCH script from a folder on one drive to a folder of the same name on another drive? 如何使用批处理脚本从一个文件中提取内容并将其复制到另一个文件? - How to Extract and copy content from one file to another using batch script? 如何使用批处理文件将一个Excel工作表中的数据复制到另一个Excel工作表中 - How to copy data of one excel sheet in another using batch file 如何将随机文件从一个文件夹复制到另一个文件夹(批处理文件) - How to copy random files from one folder to another (a batch file) 如何在批处理文件中将选定的文件从一个文件夹复制到另一个文件夹? - How to copy selected files from one folder to another in Batch file? Windows批处理文件脚本将每个第十个文件从一个文件夹复制到另一个文件夹 - windows batch file script to copy every tenth file from a folder to another folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM