批处理脚本与命令行 [英] Batch script vs command line

查看:96
本文介绍了批处理脚本与命令行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在cmd中运行以下命令时,它会起作用:

When I run following command in cmd prompt it works:

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

但是当我从.bat文件运行它时,它不起作用.说-nln是意外的.

but when I run it from .bat file it does not work. Saying -nln was unexpected.

无论如何,我可以从.bat文件中运行它.

Is there anyway I could run this from .bat file.

推荐答案

%字符对于命令行参数和FOR参数具有特殊含义.

The % character has a special meaning for command line parameters and FOR parameters.

要将百分比视为常规字符,请将其加倍:%%

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

有关更多信息,请参见: http://ss64.com/nt/syntax-esc. html

See this for more info : http://ss64.com/nt/syntax-esc.html

这篇关于批处理脚本与命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆