Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting files at DOS- promt

Status
Not open for further replies.

CoolJoe

Programmer
Dec 9, 2002
8
0
0
FR
Hi Folks!

Is it possible to delete several files with one command from a database? We've got heaps of files that are deleted (our users have only the right to delete files, not to permanent destroy them). What if I want to permanetly destroy all marked files? Is there a command I can use?

Thanks,

Calvin
 
I wrote this VBScript a few years ago to automate that task. Right now, it puts up a message box to confirm the permanent destruction of each deleted object. It can be easily changed to not prompt at all. Since its been a few years I can't verify that it works perfectly (although I'm pretty sure its just fine). It looks like it assumes the local NT user login. You need to change the VssPath and the SrcProject values at the top to whatever the appropriate location and project is for you. If you don't know and don't feel like learning VBScript, just let me know and I can tweak it for you.
Code:
' vbExclamation = 32
' vbCancel = 2
' vbYesNoCancel = 3
' vbYes = 6
' vbNo = 7
' vbDefaultButton2 = 256
vbFlags = vbExclamation + vbYesNoCancel + vbDefaultButton2

VssPath = "D:\Microsoft Visual Studio\VSS\srcsafe.ini"
SrcProject = "$/"

Dim shell
Set shell = CreateObject("WScript.Shell")

' Start the SourceSafe process and open the connection to the database
' at VSSPath (specified above).
Dim oVSSDB
Set oVSSDB = CreateObject("SourceSafe")
oVSSDB.Open VssPath

' Purge starting with the SrcProject (specified above).
SSPurge SrcProject


'*****************
' Function SSPurge
' 
' Destroys deleted items in a sourcesafe database.  This function goes
' through each item one at a time and asks the user to confirm the
' call to delete it permanently.  If the item is a project, then this
' function is called recursively on that project.
'*****************
Function SSPurge(SrcProject)
    Dim oVSSProject, oVSSItem
    Set oVSSProject = oVSSDB.VSSItem(SrcProject)
    For Each oVSSItem In oVSSProject.Items(True)
        CurObject = SrcProject + "/" + oVSSItem.Name
        If oVSSItem.Deleted Then
            retVal = shell.Popup("Do you want to destroy: " _
                + CurObject + "?", 0, "Destroy File?", vbFlags)
            Select Case retVal
            ' Case vbNo - Do nothing
            Case vbYes
                oVSSItem.Destroy
            Case vbCancel
                WScript.Quit()
            End Select
        ElseIf oVSSItem.Type = VSSITEM_PROJECT Then
            SSPurge CurObject
        End If
    Next
End Function
Copy that into a text file and name it with a .vbs extension (e.g. SSPurge.vbs). Also make sure to fix any lines that are wrapped by the forum code tags.

I recommend running it on a small test database first just in case, especially if you tweak it to remove the prompts. Remember, there is no undo if you mess up.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top