[英]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.