问题描述
我的计算机的操作系统是win7
My computer's OS is win7
我想使用.bat文件打开新的外壳,然后在新的外壳中运行脚本
I want to use a .bat file to open a new shell, then run script in a new shell
此外壳是OSGeo4W外壳
this shell is OSGeo4W Shell
它位于"C:\ Program Files \ QGIS Dufour \ OSGeo4W.bat"中
it is located in "C:\Program Files\QGIS Dufour\OSGeo4W.bat"
所以我用了
cd "C:\Program Files\QGIS Dufour\"
OSGeo4W.bat
cd "C:\Users\tony\Downloads\11\computingArea"
ogr2ogr -f CSV my_csv Grid.dbf
ogr2ogr -f CSV csv Grid.dbf
addcenter.exe
ogr2ogr -f "ESRI Shapefile" my_dir ./csv/Grid.csv
copy Grid.shp my_dir
copy Grid.shx my_dir
rd my_csv /s /q
rd csv /s /q
ogr2ogr -clipsrc t.shp test.shp ./my_dir/Grid.shp
rd my_dir /s /q
ogr2ogr -f CSV wellcsv welllocation.dbf
ogr2ogr -f CSV csv test.dbf
computingArea.exe
ogr2ogr -f "ESRI Shapefile" my_dir ./csv/test.csv
rd csv /s /q
rd wellcsv /s /q
move test.shp my_dir
move test.shx my_dir
del test.dbf /q
但是,此脚本仅打开OSGeo4W Shell
But, this script only open OSGeo4W Shell
请告诉我如何解决此问题.
Please tell me how to solve this problem.
推荐答案
我遇到了类似的问题,并且设法解决了这一问题:我有一个名为script.bat的脚本文件,其中包含各种python和ogr函数.在单独的蝙蝠文件中,我输入:
i had similar problem, and i managed to resolved like this: I had a script file called script.bat with various python and ogr functions. In separate bat file i typed:
call "C:\Program Files\QGIS 2.14\OSGeo4w.bat" start cmd.exe /k script
pause
此bat文件在OSGeo4W Shell中调用inital script.bat.
This bat file calls inital script.bat in OSGeo4W Shell.
* note1:两个bat文件必须位于同一目录中.** note2:在您的情况下,script.bat将包含以下内容:
*note1: Both bat files must be in same directory.**note2: In your case script.bat will have content:
ogr2ogr -f CSV my_csv Grid.dbf
ogr2ogr -f CSV csv Grid.dbf
addcenter.exe
ogr2ogr -f "ESRI Shapefile" my_dir ./csv/Grid.csv
copy Grid.shp my_dir
copy Grid.shx my_dir
rd my_csv /s /q
rd csv /s /q
ogr2ogr -clipsrc t.shp test.shp ./my_dir/Grid.shp
rd my_dir /s /q
ogr2ogr -f CSV wellcsv welllocation.dbf
ogr2ogr -f CSV csv test.dbf
computingArea.exe
ogr2ogr -f "ESRI Shapefile" my_dir ./csv/test.csv
rd csv /s /q
rd wellcsv /s /q
move test.shp my_dir
move test.shx my_dir
del test.dbf /q
和单独的bat文件将是:
and separate bat file will be:
call "C:\Program Files\QGIS Dufour\OSGeo4w.bat" start cmd.exe /k script
,两个bat文件都必须位于包含数据的目录中(C:\ Users \ tony \ Downloads \ 11 \ computingArea).我希望这会成功,对我有用!
and both bat files must be in directory with data (C:\Users\tony\Downloads\11\computingArea). I hope this will work, it worked for me!
这篇关于如何在cmd中打开新的shell,然后在新的shell中运行脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!