1.

Solve : If Exists, If Not Exists?

Answer»

I Have a NEED to write a batch file (executed via SQL job STEP) to VERIFY if a file in a folder is present. If so it would move the file to a archive folder. I'd need to also include If Not Exists, so that if there isn't a file to exit.

IF Exist c:\temp move K:\SQL_Backup\HR83CPY\*.* K:\SQL_Backup\HR83CPY\Archive_Backup\
IF File does not exist K:\SQL_Backup\HR83CPY
Exit

Appreciate some guidanceYour description of your task is not reflective of what your code looks like.

You are basically testing if the folder C:\TEMP exists and if it does then move all the FILES in a completely DIFFERENT folder to another folder.
But what I think you want is this.
Code: [Select]IF NOT EXIST "K:\SQL_Backup\HR83CPY\*.*" Exit
IF EXIST "K:\SQL_Backup\HR83CPY\*.*" move "K:\SQL_Backup\HR83CPY\*.*" "K:\SQL_Backup\HR83CPY\Archive_Backup\"
If this is not what you want then you will need to provide a more detailed explanation with examples.
Thanks for your suggestion. I think you have what I was looking for and will give it a try out.



Discussion

No Comment Found