Make sort of SELECT with condition IF NOT EXISTS

0

I want to make a script that only copies a file once if it exists. There is no copying or creating but if or if in .bat (Batch) the file is called:

TestBackUp.rar

is in the hard drive at the following URL

C:\BackUP\TestBackUp.rar

I wish to copy it if the following URL does NOT exist

D:\BackUP\TestBackUp.rar

The code in SQL would be something like for example:

IF NOT EXISTS (SELECT TestBackUp.rar)
COPY
ELSE
NO COPY

This is a small piece of what I have in advance:

    @echo off
:: aqui condicion IF no existe dentro del directorio D:\BackUP\TestBackUp.rar
echo Buscando y comprimiendo desde WinRaR en 32 y 64 Bits 
"C:\Program Files\WinRAR\WinRAR.exe" A -R D:\BackUp\TestBackUp.RAR "C:\BackUp\Patch" 
cls 
echo Buscando y comprimiendo desde WinRaR en 32
"C:\Program Files (x86)\WinRAR\WinRAR.exe" A -R D:\BackUp\TestBackUp.RAR "C:\BackUp\Patch" 
::Fin de condicion

cls 
rd /s /q "C:\BackUp" 
move C:\Temporal\BackUp\*.RAR D:\BackUp  
cls 
rd /s /q "C:\Temporal" 
echo. 
    ::de lo contrario

    cls 
    rd /s /q "C:\BackUp" 
    move C:\Temporal\BackUp\*.RAR D:\BackUp  
    cls 
    rd /s /q "C:\Temporal" 
    echo. 
    Exit
    
asked by Juan Carlos Villamizar Alvarez 18.11.2017 в 02:27
source

1 answer

0

The IF statement works to check for the existence of files you use in the following syntax:

IF [NOT] EXIST filename (command) ELSE (command)

On the other hand, I suggest using tags ( :Etiqueta and GOTO Etiqueta and / or CALL :Etiqueta with Goto :EOF ) to define the flow of the program better than statements within the if (For example,% Errorlevel% no it "passes" in and out of the If, and other similar behaviors.)

    
answered by 01.02.2018 в 17:39