Batch script vs command line

倖福魔咒の 提交于 2019-12-08 02:17:00

问题


When I run following command in cmd prompt it works:

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. Saying -nln was unexpected.

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


回答1:


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

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



来源:https://stackoverflow.com/questions/37095708/batch-script-vs-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!