大家好,我是编程(在实践中)的菜鸟已经完成了一些课程,如果我浪费你的时间来处理我的问题,我会提前道歉。
我想使用我已经制作的批处理文件处理图像,问题是我需要使用他们的文件名作为输入处理100多个图像,并想知道如何使这成为可能吗?
我的脚本看起来像这样
@echo on
echo file name convention:M02-ASCA-ASCSMR02-NA-3.2-20140129081200.000000000Z-1095218.bfr
echo test from UMARF
echo note orbit number as %9
rem set orbitnumber=%9
set longfilename= %filename%
rem: shorfilename1=yyyymmdd
set shortfilename1=%longfilename:~26,12%
echo shortfilename1
pause
set PATH=%D:\geonetcast\Software\ILWIS\Ilwis372_oct2012\Extensions\GEONETCast-Toolbox\util%
call 7z.exe e %longfilename%.bz2
pause
echo on
set PATH=%D:\geonetcast\Software\ILWIS\Ilwis372_oct2012\Extensions\GEONETCast-Toolbox\util%
pause
rem: Ascat surface soil moisture
rem: in top 5 cm of soil
rem: output point map is estimate of water saturation from 0-100%
set VBUFR_TABLE_DIR=D:\geonetcast\Software\ILWIS\Ilwis372_oct2012\Extensions\GEONETCast-Toolbox\util\tables
set VBUFR_DATA_DIR=D:\test
call bufrtool.exe pick %longfilename% 6001 5001 40001 40002 40003 40007 > D:\test\%shortfilename1%_org.txt
call deletelines.exe D:\test\%shortfilename1%_org.txt D:\test\%shortfilename1%_imp.txt 7
copy D:\geonetcast\Software\ILWIS\Ilwis372_oct2012\Extensions\GEONETCast-Toolbox\util\asc.dm#
copy D:\geonetcast\Software\ILWIS\Ilwis372_oct2012\Extensions\GEONETCast-Toolbox\util\asc.dom %shortfilename1%.dom
set PATH=%D:\geonetcast\Software\ILWIS\Ilwis372_oct2012%
call ilwis.exe -C D:\test\%shortfilename1%.tbt:=table(D:\test\%shortfilename1%_imp.txt,Space,Convert,none,ID(D:\test\%shortfilename1%.dom{id}),X(value.dom{-180:180:0.00001}),Y(value.dom{-90:90:0.00001}),SM_perc(value.dom{0:100:0.01}),Error_perc(value.dom{0:100:0.01}),Mean_SM(value.dom{0:100:0.0001}),Quality(value.dom{0:100:1}));
call ilwis.exe -C D:\test\%shortfilename1%_smperc.mpp:=PointMapFromTable(D:\test\%shortfilename1%,LatlonWGS84,SM_perc);
rem
结束
(我知道有点长) - 我已经搜索了一个我可以使用的解决方案但是目前正在努力,我在另一个网站上发现了这个代码,但是无法让它为我的itteration工作,
FileList = dir('*.csv');
N = size(FileList,1);
for k = 1:N
% get the file name:
filename = FileList(k).name
disp(filename);
% insert your script code here
真的很感激一些帮助。
此致 J-BON3
答案 0 :(得分:1)
For %A in (c:\windows\*.ini) do echo %A
在批处理文件中,您在命令提示符下使用%% AN而不是%A。参见
for /?
您还可以看到
forfiles /?
答案 1 :(得分:1)
如果您有文件中的文件列表。像这样:
FileList.txt:
File1.xxx
File2.xxx
File3.xxx
File5.xxx
您可以使用简单的FOR
循环和CALL
来执行您想要的操作:
@echo off
for /f "delims=" %%a in ('type filelist.txt') do call:Work %%a
Echo Done ...
exit/b
:work
set $file=%1
echo Treating File : [%$file%]
输出:
Treating File : [File1.xxx]
Treating File : [File2.xxx]
Treating File : [File3.xxx]
Treating File : [File5.xxx]
Done ...