简体   繁体   English

批处理脚本与命令行

[英]Batch script vs command line

When I run following command in cmd prompt it works: 当我在cmd提示符下运行以下命令时,它将起作用:

for /R %f in (*.shp) do ogr2ogr -nln merge -update -append merge.shp %f 

but when I run it from .bat file it does not work. 但是当我从.bat文件运行它时,它不起作用。 Saying -nln was unexpected. 说-nln是意外的。

Is there anyway I could run this from .bat file. 无论如何,我可以从.bat文件运行此文件。

The % character has a special meaning for command line parameters and FOR parameters. %字符对于命令行参数和FOR参数具有特殊含义。

To treat a percent as a regular character, double it: %% 要将百分比视为常规字符,请将其加倍: %%

When you execute it from a batch file, you should write it like this : 从批处理文件执行时,应这样编写:

@echo on
for /R %%f in (*.shp) do ogr2ogr -nln merge -update -append merge.shp %%f 
pause

See this for more info : http://ss64.com/nt/syntax-esc.html 看到更多信息: http : //ss64.com/nt/syntax-esc.html

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM