Computer Hope
Microsoft => Microsoft DOS => Topic started by: _unknown_ on November 30, 2014, 07:27:42 PM
-
The script indicated in here will merge files from the in_path and now will successfully move the merged files only to another directory which is the proc_path. The goal now is to merge the files based on the date of the last processed files and so on. So that whenever the system is down and you weren't able to process the files let's say for one week, it will just check for the last date where it stop and process it and then process the next date and so on. But how can I do that? Any idea?
Thank you!
@echo on
setlocal EnableDelayedExpansion
rem Modify following variables
set "in_path=E:\Proc\Pro\"
set "out_path=E:\Proc\Mer"
set "proc_path=E:\Proc\Proc_Pro"
rem DON'T modify the following variables
set "yearDay="
set "fileList="
set "numFiles=0"
md %out_path%
md %proc_path%
rem Process all *.tif files in input path
pushd "%in_path%"
for %%a in (*.tif) do (
set "fileName=%%a"
rem If the YearDay in this file is the same of previous one
if "!fileName:~1,7!" equ "!yearDay!" (
rem Join this filename to previous list
set "fileList=!fileList!!fileName! "
set /A numFiles+=1
) else (
rem Merge the files in the list if there are more than 2, in the out_path leaving only TYYYYDDD.L2_LAC.Tera.tif
if !numFiles! gtr 2 (
gdal_merge.py -n 0 -a_nodata -32767 -of GTiff -o %out_path%\T!yearDay!.L2_LAC.Tera.tif !fileList!
rem Move processed files to a different directory
set "fileList=!fileList:~0,-1!"
move !fileList: =,! "%proc_path%"
)
rem And start a new YearDay and fileList
set "yearDay=!fileName:~1,7!"
set "fileList=!fileName! "
set numFiles=1
)
)
rem Merge the files in the last list if there are more than 2
if !numFiles! gtr 2 (
gdal_merge.py -n 0 -a_nodata -32767 -of GTiff -o %out_path%\T!yearDay!.L2_LAC.Tera.tif !fileList!
set "fileList=!fileList:~0,-1!"
move !fileList: =,! "%proc_path%"
)
popd
-
Not sure why you are posting this here when you already got the original code from DosTips.com. The helpers over there already know what the code does and can probably do a better job of helping you with any changes you need.
-
Not sure why you are posting this here when you already got the original code from DosTips.com. The helpers over there already know what the code does and can probably do a better job of helping you with any changes you need.
But I still need help with this. The question above is the last thing that I still need in order to have it done. And I don't know how to do it.