此批处理文件只能运行一行

时间:2011-06-30 17:46:04

标签: python batch-file gdal

gdal_merge -o C:\test\RasterMerge\p023r027\p023r027_7t20010623_z16_merged.tif -seperate -q -v C:\test\RasterMerge\p023r027\p023r027_7t20010623_z16_merged.tif C:\test\RasterMerge\p023r027\p023r027_7t20010623_z16_nn10.tif C:\test\RasterMerge\p023r027\p023r027_7t20010623_z16_nn20.tif 
gdal_merge -o C:\test\RasterMerge\p024r027\p024r027_7t19990828_z16_merged.tif -seperate -q -v C:\test\RasterMerge\p024r027\p024r027_7t19990828_z16_nn10.tif C:\test\RasterMerge\p024r027\p024r027_7t19990828_z16_nn20.tif
gdal_merge -o C:\test\RasterMerge\p024r027\p023r026\p023r026_7t20001010_z16_merged.tif -seperate -q -v C:\test\RasterMerge\p024r027\p023r026\p023r026_7t20001010_z16_nn10.tif C:\test\RasterMerge\p024r027\p023r026\p023r026_7t20001010_z16_nn20.tif 
gdal_merge -o C:\test\RasterMerge\p024r027\p024r026\p024r026_7t20000729_z16_merged.tif -seperate -q -v C:\test\RasterMerge\p024r027\p024r026\p024r026_7t20000729_z16_nn10.tif C:\test\RasterMerge\p024r027\p024r026\p024r026_7t20000729_z16_nn20.tif 
gdal_merge -o C:\test\RasterMerge\p024r027\p023r026\p023r028\p023r028_7t20000519_z16_merged.tif -seperate -q -v C:\test\RasterMerge\p024r027\p023r026\p023r028\p023r028_7t20000519_z16_nn10.tif 

C:\test\RasterMerge\p024r027\p023r026\p023r028\p023r028_7t20000519_z16_nn20.tif 

注意:我已从每个命令中删除了其他5个文件名,以使其更具可读性。 我正在开发一个Python工具,它将为我构建一个批处理文件但是当我尝试运行这个.bat时,我得到的是第一个成功运行然后返回控制台的命令。我在FWTools shell中运行它。我已经在十六进制编辑器中打开了批处理文件,并搜索了额外的换行符并返回了字符,但我没有看到任何与众不同的内容,因此Python似乎正在正确编写。

1 个答案:

答案 0 :(得分:4)

gdal_merge批处理文件本身吗?

在这种情况下,您需要在每行之前输入call以提示批处理文件在从被调用批处理文件退出时返回,否则新批处理文件中的退出调用将被视为实际退出,因此应完全退出:

call gdal_merge -o C:\test\RasterMerge\p023r027\p023r027_7t20010623_z16_merged.tif -seperate -q -v C:\test\RasterMerge\p023r027\p023r027_7t20010623_z16_merged.tif C:\test\RasterMerge\p023r027\p023r027_7t20010623_z16_nn10.tif C:\test\RasterMerge\p023r027\p023r027_7t20010623_z16_nn20.tif 
call gdal_merge -o C:\test\RasterMerge\p024r027\p024r027_7t19990828_z16_merged.tif -seperate -q -v C:\test\RasterMerge\p024r027\p024r027_7t19990828_z16_nn10.tif C:\test\RasterMerge\p024r027\p024r027_7t19990828_z16_nn20.tif
...

(python本身也可能通过批处理文件运行,但同样适用,但也可能使用call python gdal_merge.py -o ...

如果这不是批处理文件,请尝试使用start /B而不是call,因为这会分叉一个新的后台任务。如果您需要按顺序而不是并行调用它们,那么只需使用start /B /WAIT