Finally I finished the code, as I imagined it was great, but not as much as I thought it would (This SCRIPT was one level above the FILES folder):
Comments show how I did each step
SET YNOW=%date:~-4%
SET YSIX=%date:~-4%
SET MNOW=%date:~-7,2%
SET /A MSIX=%mnow% - 6
REM ############### VERIFICAR ANO
IF %msix% LEQ 0 (SET /A YSIX=YNOW - 1)
REM ############### VERIFICAR MESES
REM ### igual a 0 equivale mes 12 do ano anterior
IF %msix% EQU 0 (SET MSIX=12)
REM ### NUMEROS NEGATIVOS
IF %msix% LSS 0 (SET /A MSIX=12%msix%)
REM ### MENOR QUE 10
IF %msix% LSS 10 (SET MSIX=0%msix%)
SET XMLS=bkp_%ysix%%msix%.xml
SET LOGS=log_%ysix%%msix%.tmp
echo ############## DELETAR XMLS ANTES DE %ysix%%msix%
dir FILES\*.xml /b>xml.log
FOR /F %%X IN (xml.log) DO (
IF %%X LSS %xmls% (del FILES\%%X)
)
echo ####### END XMLS
echo ############## DELETAR LOGS ANTES DE %ysix%%msix%
dir FILES\*.tmp /b>tmp.log
FOR /F %%L IN (tmp.log) DO (
IF %%L LSS %logs% (del FILES\%%L)
)
echo ####### END LOGS
pause
Batch Script - Old delete
As I was not at work I did on my Windows 8 personal, to make sure it would work, I installed a virtual machine in my notebook, and I ran the tests on it and it worked, to be frank I was getting in a single detail, but however incredible the command line looks like the names of the files containing numbers, for example:
REM A Verficar Data 6 meses
IF bkp_201706.xml LSS bkp_201709.xml (
echo ESTE ARQUIVO TEM MAIS DE 6 MESES
) ELSE (
echo ESTE ARQUIVO TEM MENOS DE 6 MESES
)
Returned ESTE ARQUIVO TEM MAIS DE 6 MESES
REM A Verficar Data 6 meses
IF bkp_201803.xml LSS bkp_201709.xml (
echo ESTE ARQUIVO TEM MAIS DE 6 MESES
) ELSE (
echo ESTE ARQUIVO TEM MENOS DE 6 MESES
)
Returned ESTE ARQUIVO TEM MENOS DE 6 MESES