When I download jpegs from an unreliable website, the downloads are often incomplete. Is there a wget option to delete incomplete downloads?
1 Answer
You can check the exit status of wget
set "output=x:\somewhere\myFile.dat" wget -O "%output%" "http://somewhere.com/this" if errorlevel 1 del "%output%" 2>nul Or using conditional execution operator || (execute next command if the previous fails)
set "output=x:\somewhere\myFile.dat" wget -O "%output%" "http://somewhere.com/this" || ( 2>nul del "%output%" ) note: Of course, you don't need the variable, just included to avoid having to write the same file name in both commands.