Avatar of eagle00789
eagle00789Flag for Netherlands

asked on 

Hide some output in batch file

This question is in relation to https://www.experts-exchange.com/questions/23566786/modify-output-of-del-command.html
I now have the correct output of my script and it does exactly what i want, but i have to much output.
I'm getting this as output if there was nothing to delete:
--
[Cleanup] Cleaning up download directory: Y:\Newsleecher\downloads\complete\Games\SafeCracker
[Cleanup] Deleteing .nzb files
Bestand niet gevonden (File not found)
[Cleanup] Deleteing .sfv files
Bestand niet gevonden (File not found)
[Cleanup] Deleteing .url files
Bestand niet gevonden (File not found)
[Cleanup] Deleteing .db files
Bestand niet gevonden (File not found)
[Cleanup] Deleted 0 files (0 nzb, 0 sfv, 0 url, 0 db)
--
but i'm expecting this as output:
--
[Cleanup] Cleaning up download directory: Y:\Newsleecher\downloads\complete\Games\SafeCracker
[Cleanup] Deleteing .nzb files
[Cleanup] Deleteing .sfv files
[Cleanup] Deleteing .url files
[Cleanup] Deleteing .db files
[Cleanup] Deleted 0 files (0 nzb, 0 sfv, 0 url, 0 db)
--
@echo off
setlocal
set fcount=0
set nzbcount=0
set sfvcount=0
set urlcount=0
set dbcount=0
 
echo.
echo [Cleanup] Cleaning up download directory: %1
 
echo [Cleanup] Deleteing .nzb files
for /f %%V in ('dir %1*.nzb /b /s ^| find /v /c ""') do set/a nzbcount = %%V
del /s /q "%1"*.nzb > NUL 2>NUL
 
echo [Cleanup] Deleteing .sfv files
for /f %%V in ('dir %1*.sfv /b /s ^| find /v /c ""') do set/a sfvcount = %%V
del /s /q "%1"*.sfv > NUL 2>NUL
 
echo [Cleanup] Deleteing .url files
for /f %%V in ('dir %1*.url /b /s ^| find /v /c ""') do set/a urlcount = %%V
del /s /q "%1"*.url > NUL 2>NUL
 
echo [Cleanup] Deleteing .db files
for /f %%V in ('dir %1*.db /b /s ^| find /v /c ""')  do set/a dbcount  = %%V
del /s /q "%1"*.db > NUL 2>NUL
 
set/a fcount = %nzbcount% + %sfvcount% + %urlcount% + %dbcount%
 
echo [Cleanup] Deleted %fcount% files (%nzbcount% nzb, %sfvcount% sfv, %urlcount% url, %dbcount% db)
echo.

Open in new window

Windows Batch

Avatar of undefined
Last Comment
eagle00789
ASKER CERTIFIED SOLUTION
Avatar of knightEknight
knightEknight
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
Avatar of B.J. Davis
B.J. Davis
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
Avatar of trythisone
trythisone
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
Avatar of B.J. Davis
B.J. Davis
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
Avatar of trythisone
trythisone
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of eagle00789
eagle00789
Flag of Netherlands image

ASKER

Thx everyone. i awarded each answer with 100 points because everyone helped with the answer. Thx everybody :D it worked like a charm the output is now as i should like it...
Windows Batch
Windows Batch

Batch files are text files containing a script of commands that are executed by the command interpreter on DOS, OS/2 and Windows systems. Most commonly, they are used to perform a series of functions that are repeated -- copying a set of files created daily with one step, for example.

13K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo