lundi 30 novembre 2020

Problems while comparing years and sizes of file in batch

I've a doubt for doing a comparison (if statement's) inside a for loop: I've a lot of files inside a folder, and I want to make two comparisons:

  1. If the file was created at the current year (!dateFile:~6,4! equ %date:~6,4%)
  2. If the size of the file is 0 bytes (%%~Za equ 0)

When I find a file that complies these conditions, I want to show "ok".

I've the next line of code, but it doesn't work:

    for /f "tokens=* delims= " %%a in ('dir /s/b/a-d "FOLDER\"') do set dateFile=%%~ta if ((!dateFile:~6,4! equ %date:~6,4%) & (%%~Za equ 0)) echo "ok"

Some help? Thanks :)

Aucun commentaire:

Enregistrer un commentaire