Batch processing

Dear sen2cor users,

could you please give me a hint how to automatically call sen2cor for e.g. 20 L1C sentinel product in one directory? I know that I can use SNAP but it doesnt work for me from some reason (I got an error, when called gdal is not existing) but a single processing from command lines works perfectly. (WINDOWS)
So i have tried cal python script with something like
import os
os.system(r’L2A_Process --resolution 10 C:\sentinel\Jizerka\2016\input\S2A_OPER_PRD_MSIL1C_PDMC_20160429T215735_R022_V20160429T101028_20160429T101028.SAFE’)
os.system(r’L2A_Process --resolution 10 C:\sentinel\Jizerka\2016\input\S2A_OPER_PRD_MSIL1C_PDMC_20160506T210005_R122_V20160506T100527_20160506T100527.SAFE’)

but this ended up with error. I believe it it because that tries to process everything in paralel and there is a limit for memory, etc. But I don’t need a parallel approach, just some chain or order processing is enough.

Thank you very much


1 Like

I’m not sure, maybe it works if you add ‘call’ in front of each process call.
Or even better you use the subprocess module to spawn the processes.

Adding ‘call’’ doesn’t work for me.

I have tried different thing: to call this in command line:

for /D %F in (C:\sentinel\Jizerka\2016\input\S2A_OPER_PRD_MSIL1C*) do L2A_Process --resolution 10 %F

but no success and the result is the same:


so I have solved it.

probably the original aproach might work as well but the following works fine:

in conda:

for /D %s in (<PATH/TO/sentinelFolder>\S2A_OPER_PRD_MSIL1C*) do L2A_Process %s --resolution=10

But - the error could happens - in case you have already proccesed or partially processed (the structure is created) some products. From some reason, there is no check of a status of process and so that no proper end of loop (but the same error hapens during single processing by the same condition of the presence of bad results).


Thank you very much!!

I could do it without problems!! only I´ve changed one * for S2A and S2B files.

“for /D %s in (C:\Teledete\Diciembre\S2*_MSIL1C*) do L2A_Process %s --resolution=10”


Hi, I have tried to do the sen2cor batch with the command in the comments but have this error -

‘L2A_Process’ is not recognized as an internal or external command, operable program or batch file

This was the command “for /D %s in (C:\File\sen2cor\S2*_MSIL1C*) do L2A_Process %s --resolution=10”

I have checked the python in snap command prompt and it was OK.

Any solution would be highly appreciated!

you can add the full path to L2A_Process to make it run, e.g.

for /D %s in (C:\File\sen2cor\S2*_MSIL1C*) do c:\sen2cor\L2A_Process %s --resolution=10

Thanks for your comments @ABraun. Now its can call the command but I got another error massage. Please see below,

C:\Sen2Cor\L2A_Process.bat C:\data\S2A_MSIL1C_20170818T103021_N0205_R108_T32TMT_20170818T103421.SAFE --resolution=10
Operation mode PDGS is not supported for Product version 14.2.
Operation mode will be reset to TOOLBOX.

Sentinel-2 Level 2A Processor (Sen2Cor). Version: 2.5.5, created: 2018.03.19, supporting Level-1C product version <= 14.5 started …
Product version: 14.2. Operation mode: TOOLBOX. Processing baseline: 02.05.
Cannot create the config object configPic.p, parent folder may be write protected.

For your kind information, the output folder is not write protected. I downloaded the data from Copernicus Open Access with my personal ID. Any solution?