WindowsDan WindowsDan - 2 years ago 84
Bash Question

Batch Script IF statement to DO something when size of all file types else DO different

I need a batch script to do a command if files of a certain type over a certain size exist but the do another command to files of the same type the are under a certain size.
I then need the script to run another command if the first instance is true but the files contain something in the title.
Below is the current script however I do not want the 3 lines at the bottom to run when only 1 or 2 are required:

TASKKILL /IM "Plex Media Server.exe" /F
cd "C:\folder\Desktop"
robocopy "L:\folder1" *.mkv /mov /MAX:3200000000 /XF *keep*
robocopy "L:\folder2" *.mkv /mov /MIN:3200000000 /XF *.h-sbs.mkv *.h-ou.mkv *keep*
robocopy "L:\folder3" *.h-sbs.mkv *.h-ou.mkv /mov /MIN:3000000000
del *.sub *.idx *.html *.nfo *.sup *.txt *.htm
START "" "C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Server.exe"
cd "C:\Program Files (x86)\Plex\Plex Media Server"
"Plex Media Scanner.exe" --scan --refresh --section 1
"Plex Media Scanner.exe" --scan --refresh --section 2
"Plex Media Scanner.exe" --scan --refresh --section 3
netsh interface set interface name="LAN 2" admin=enabled

Answer Source

This might get you started.

@echo off
for %%I in (*.txt) do (
    @echo File "%%~nI" is %%~zI bytes
    if %%~zI GTR 1000 echo This is larger than 1kb!
    if %%~zI LSS 1000 echo This is not 1kb :(
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download