Command to automatically override existing databases/files
Forums
Hello everyone!
When preparing an IDEA script, is there any command I can use that will tell IDEA to automatically override any existing database in the project and/or existing files the script might create?
I have scripted more with ACL and in ACL, that command is SET SAFETY OFF. When this command is used in a script, any existing ACL table or file that is created by the script will be automatically overridden.
I was checking to see if IDEA had a similar command.
Thanks in advance for the help!
Mike
Hi JHDCC, when they were
Hi JHDCC, when they were putting the scripting language together they decided not to add that function, the reason for that is probably lost in time.
What you can do is first check if the file exists and if it does delete it manually before doing the save. Here is some code for you to do it.
Sub Main
Call deleteFileIfExists("C:\Users\User\Documents\My IDEA Documents\file to delete.xls")
End Sub
Function deleteFileIfExists(sFilename As String)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(sFilename)) Then
fso.DeleteFile sFilename
End If
End Function
Thanks Brian
Thanks Brian
For the benefit of anyone else picking this up, rename the path in this line with the file you want to delete and include this in the top of the macro between the Sub Main and End Sub lines. Include a seperate line for each file which is to be deleted.
<code>
Call deleteFileIfExists("C:\Users\User\Documents\My IDEA Documents\file to delete.xls")
</code>
Include the below in the body of the macro. This does not need altering and only needs including once it seems - I presume the file path in the top section is inserted into the function and it runs for each instance.
<code>
FunctiondeleteFileIfExists(sFilename As String)DimfsoSetfso = CreateObject("Scripting.FileSystemObject")If(fso.FileExists(sFilename))Thenfso.DeleteFilesFilenameEndIfEndFunction
</code>
Hi Mike,
Hi Mike,
Sorry for not getting back to you sooner. The command you are looking for is:
IgnoreWarning(True)
Just add this at the beginning of the script and you won't get any pop-ups asking you to overwrite files that already exists.
Brian