简体   繁体   English

我正在尝试在批处理文件中执行许多命令。 我需要对一批.tiff文件执行处理

[英]I'm trying to perform a number of commands in a batch file. I need to perform a process on a batch of .tiff files

I'm trying to perform a sequence of commands in a batch file. 我正在尝试在批处理文件中执行一系列命令。 I need to perform a process on a batch of .tiff files then move the output .tiff files to another location and perform another process on the original .tiff files. 我需要对一批.tiff文件执行一个过程,然后将输出的.tiff文件移动到另一个位置,并对原始.tiff文件执行另一个过程。 The code I am trying is below; 我正在尝试的代码如下;

for %f in (*.tiff) do gdaldem_slope_batch.bat %~nf & move /-y "C:\Users\wmiller\Desktop\temp\*slope*.tiff" "C:\Users\wmiller\Desktop\trial" & for %f in (*.tiff) do gdaldem_hillshade_batch.bat %~nf & move /-y "C:\Users\wmiller\Desktop\temp\*hillshade*.tiff" "C:\Users\wmiller\Desktop\trial" 

My problem is that it does the first command on the first file and moves it to the new location it then runs through the second command on all the files in turn and moves them to the new location. 我的问题是它在第一个文件上执行第一个命令,然后将其移动到新位置,然后依次在所有文件上运行第二个命令,并将它们移动到新位置。 It then performs the first command on the second file and subsequently tries to run through the second command on all files attempting to create duplicates of the files already there. 然后,它对第二个文件执行第一个命令,随后尝试对所有文件运行第二个命令,以尝试创建已存在的文件的副本。

Any advice, this is my first attempt at programming (incase you can't tell) so be gentle. 任何建议,这是我第一次尝试编程(以防万一),所以要谦虚。

Thanks 谢谢

I need to perform a process on a batch of .tiff files then move the output .tiff files to another location and perform another process on the original .tiff files. 我需要对一批.tiff文件执行一个过程,然后将输出的.tiff文件移动到另一个位置,并对原始.tiff文件执行另一个过程。

Here's how you want to group the commands then (also changed to %% batch file syntax): 然后,您要对命令进行分组(也已更改为%%批处理文件语法):

for %%f in (*.tiff) do ( 
  call gdaldem_slope_batch.bat %%~nf 
  move /-y "C:\Users\wmiller\Desktop\temp\*slope*.tiff" "C:\Users\wmiller\Desktop\trial"
)
for %%f in (*.tiff) do (
  call gdaldem_hillshade_batch.bat %%~nf
  move /-y "C:\Users\wmiller\Desktop\temp\*hillshade*.tiff" "C:\Users\wmiller\Desktop\trial"
)

If you really wanted this on one line as in the question, though usually discouraged, that can be done by grouping the entire first for command as follows: 如果你真的想这个在一行中的问题,尽管通常气馁, 可以通过分组整个第一完成for命令如下:

(for %%f in (*.tiff) do call gdaldem_slope_batch.bat %%~nf & move /-y "C:\Users\wmiller\Desktop\temp\*slope*.tiff" "C:\Users\wmiller\Desktop\trial") & for %%f in (*.tiff) do call gdaldem_hillshade_batch.bat %%~nf & move /-y "C:\Users\wmiller\Desktop\temp\*hillshade*.tiff" "C:\Users\wmiller\Desktop\trial"

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

相关问题 如何运行进程,等待它闲置,然后从Windows批处理文件中将其杀死。 - How can I run a process, wait for it to idle and then kill it from a windows batch file. 根据批处理文件中的变量值执行操作 - Perform action depending on variable value in Batch Files 如何根据已安装程序的最新版本在Windows批处理文件中执行不同的操作 - How can I perform different actions in windows batch file based on most recent version of installed program 我正在尝试使用Windows批处理文件将数据从stdin(到日志文件)中加时间戳 - I'm trying to timestamp data from stdin (into a log file) using a Windows Batch file 我需要这个批处理文件供初学者使用 - I need this batch file to be interpreted for a beginner 我需要建议批处理文件代码 - I need advise on batch file code 需要批处理文件才能移动文件 - Need a batch file to move files 我正在寻找一个批处理脚本,它将多个文本文件的名称附加到每个文件的第一行 - I'm looking for a batch script that appends the names of multiple text files to the first line of each file 如何在批处理文件中将命令传递给提升的应用程序? - How can I pass commands to the elevated application in a batch file? 如何记录BATCH文件中的所有ECHO命令? - How do I make a log of all ECHO commands in a BATCH file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM