exit when no CSVs found

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Vsharmac@gmail.com
Posts: 1
Joined: 01 Nov 2017 20:26

exit when no CSVs found

#1 Post by Vsharmac@gmail.com » 01 Nov 2017 20:29

Hi,

I am a newbie in batch scripting and would like to figure out how to check if any csv exists on "\\ftpserver\Dump\DEPARTMENT" location. if there are no csv files then the script
should exit without running any other command but if there are csv exists then move all the csv to "\\ftpserver\Dump\DEPARTMENT\run\" and execute the program should follow.


cd "\\ftpserver\Dump\DEPARTMENT"

REM move the files to the run folder "\\ftpserver\Dump\DEPARTMENT\run\"
move /Y "\\ftpserver\Dump\DEPARTMENT\*.csv" "\\ftpserver\Dump\DEPARTMENT\run\"

REM run the SCB Job
@ECHO off
"C:\Program Files\SCB\Workbench.exe" run-job -s test.scb.com -j 232

REM Move the files from the run to processed folder "\\ftpserver\Dump\DEPARTMENT\processed\"
move /Y "\\ftpserver\Dump\DEPARTMENT\run\*.csv" "\\ftpserver\Dump\DEPARTMENT\processed\"

Regards,
Vick

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: exit when no CSVs found

#2 Post by penpen » 02 Nov 2017 03:35

It seems there is missing only the "csv-check" part:

Code: Select all

@echo off
if not exist *.csv goto :eof

:: insert your other code here
For further information type "if /?" and "goto /?" (without doublequotes) into the command shell (cmd.exe).


penpen

Post Reply