[英]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.