简体   繁体   English

使用特定文件名批量迭代文件列表

[英]Batch iteration of file list using specific filenames

Hi all i am a noob to programming (in practice) have done some courses though, and i apologise in advance if i am wasting your time with my problem. 大家好,我是编程的新手(实际上)已经完成了一些课程,如果我浪费您的时间来解决我的问题,我事先表示歉意。

I would like to process images using a batch file that i have made already, the problem is i need to process 100+ images using their file name as an input and would like to know how to make this possible? 我想使用我已经制作的批处理文件来处理图像,问题是我需要使用其文件名作为输入来处理100多个图像,并且想知道如何做到这一点?

my script looks like this 我的脚本看起来像这样

@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

end 结束

(i know a tad long)- i have searched for a solution i can use but am struggling at present, I found this code on another site but can't get it to work for my 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

would really appreciate some help. 非常感谢您的帮助。

Regards J-bon3 关于J-bon3

For %A in (c:\windows\*.ini) do echo %A

In a batch file you use %%A rather than %A at a command prompt. 在批处理文件中,在命令提示符下使用%% A而不是%A。 See 看到

for /?

You can also see 你也可以看到

forfiles /?

If you have the list of the files in a file. 如果文件中有文件列表。 Like this : 像这样 :

FileList.txt : FileList.txt:

File1.xxx
File2.xxx
File3.xxx
File5.xxx

You can use a simple FOR loop with a CALL to do what you want : 您可以将简单的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%]

Output : 输出:

Treating File : [File1.xxx]
Treating File : [File2.xxx]
Treating File : [File3.xxx]
Treating File : [File5.xxx]
Done ...

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM