S
S
Sergey Lehmann2021-01-15 14:21:33
cmd/bat
Sergey Lehmann, 2021-01-15 14:21:33

Checking condition in bat command?

There is a simple script

@echo off
mkdir "Z:\1c_backup\Backup-%date:.=%"
xcopy /E "C:\1c_backup" "Z:\1c_backup\Backup-%date:.=%\"
TIMEOUT /T 2 /NOBREAK
rd /s /q "C:\1c_backup"
md "C:\1c_backup"
TIMEOUT /T 10 /NOBREAK


How can I make sure that before deleting , it checks if the condition is met ? If not, then stop running the script. rd /s /q "C:\1c_backup"mkdir "Z:\1c_backup\Backup-%date:.=%"

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Saboteur, 2021-01-15
@saboteur_kiev

@echo off
set MYDIR="Z:\1c_backup\Backup-%date:.=%\"
mkdir %MYDIR%
echo xcopy /E "C:\1c_backup" %MYDIR%
TIMEOUT /T 2 /NOBREAK
IF NOT EXIST %MYDIR% exit 1
rd /s /q "C:\1c_backup"
md "C:\1c_backup"
TIMEOUT /T 10 /NOBREAK

L
lik173, 2021-01-16
@lik173

Try
if exist Backup goto continue
if not exist Backup exit
or something like that

K
Korben5E, 2021-01-19
@Korben5E

set xx=0
mkdir "Z:\1c_backup\Backup-%date:.=%" && set xx=1
if xx.........
something like this :-)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question