## Display commands only if file exists

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
activoice
Posts: 2
Joined: 11 Nov 2018 14:30

### Display commands only if file exists

So I have this batch files that looks at the filenames for various videos that I download and moves them from a common folder to a destination folder. It runs fine, but it looks messy in the command window as it displays a line for every file that it checks to see if it exists.. I would like to only display the commands in the window for files that actually exist, and not see all of the ones that no file existed for...

For example my batch file currently looks like this
movefiles.cmd

But if I run this and only the file def.mkv exists I still see all 3 commands in the command window

Instead I would like to only see the one line for the file that does actually exist and that it's moving

Is there a way to do that? Perhaps with the Echo command?

Squashman
Expert
Posts: 4013
Joined: 23 Dec 2011 13:59

### Re: Display commands only if file exists

At the top of your script use the ECHO command to turn off verbose output of other command.

Code: Select all

@echo off

activoice
Posts: 2
Joined: 11 Nov 2018 14:30

### Re: Display commands only if file exists

Wow thanks, didn't realize it was that simple