Solved

Automate script to delete folders in Windows Vista

Posted on 2011-03-10
5
368 Views
Last Modified: 2012-05-11
Hi,

I'd like to create a simple script in Windows Vista to delete .svn folders recursively in all subfolders of C:\wamp\www\discoup9_v3

Here's a snapshot:
http;//tutorialref.com/images/delete-svn-folders-script-windows-vista.png

I'm using Vista Home Premium.

Thanks,
Victor
0
Comment
Question by:Victor Kimura
  • 3
5 Comments
 
LVL 12

Expert Comment

by:prashanthd
ID: 35094045
Try the following code.

You may require elevated privileges in Vista

http://www.lytebyte.com/2008/10/22/how-to-run-as-administrator-in-vista-command-line/
On Error Resume next

Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "C:\wamp\www\discoup9_v3"

Set objFolder = objFSO.GetFolder(objStartFolder)

ShowSubfolders objFSO.GetFolder(objStartFolder)

Sub ShowSubFolders(Folder)
    For Each Subfolder In Folder.SubFolders
        'WScript.Echo Subfolder.Path
       		If Subfolder.name = ".svn" Then
       			'WScript.Echo Subfolder.Path
       			Err.Clear
       			objfso.DeleteFolder subfolder.path,True
       			If Err.Number<>0 Then
       				WScript.Echo subfolder.path &" - Err Number:"& Err.Number & " Err Description: " & Err.Description 
       			End if
       		End If
        	ShowSubFolders Subfolder
    Next
End Sub

Open in new window

0
 
LVL 52

Expert Comment

by:Bill Prew
ID: 35099379
Why not just do the following either at a command prompt, or in a BAT file?

DEL /S /Q "C:\wamp\www\discoup9_v3\*.svn"

Open in new window

~bp
0
 
LVL 12

Accepted Solution

by:
prashanthd earned 500 total points
ID: 35108102
0
 

Author Comment

by:Victor Kimura
ID: 35110303
Hi billprew,

It's stating access denied. I'm logged in as admin and ran the cmd as admin.

-----------
To prashanthd,

I grabbed the code from the 2nd link (http://www.technospot.net/blogs/how-to-remove-svn-folders-from-your-source-files/). What code is the following? How do I run it in Vista?

FileSelectFolder, folder, %A_Desktop%
Loop, %folder%\*.*, 2, 1
{
	FileFullPath := A_LoopFileLongPath
	IfInString, FileFullPath, .svn
		FileRemoveDir, %FileFullPath%, 1
}

Open in new window


----
To prashanthd,

With regards to the code you gave, how do I run that code? Do I need a VB editor and run it from the development environment?

BTW, this link:
http://tomgilkison.blogspot.com/2008/07/delete-svn-folders-windows-vista.html

simply stated to use advanced search and delete them and I think that works. I just want to know how the code you gave works and how to run it.

Much thanks,
Victor

0
 
LVL 12

Assisted Solution

by:prashanthd
prashanthd earned 500 total points
ID: 35111004
http://www.technospot.net/blogs/how-to-remove-svn-folders-from-your-source-files/
Do not run the code, right above the code on the download webpage, there is a link svnremover, download the tool and run.

http://tomgilkison.blogspot.com/2008/07/delete-svn-folders-windows-vista.html

The above link also states that advanced search will not work for Vista, you can try it.

As mentioned in above link

Copy the text and paste it into a text file called 'svn.reg'. Save the file and open it to add these keys to your registry. Then all you have to do is right-click on the folder and choose "Delete SVN Folders". It's even easier than the Search and Delete method :)

Copy the below lines from Windows Registry Editor Version 5.00 into svn.reg and follow above instructions


Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN]
@="Delete SVN Folders"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN\command]
@="cmd.exe /c \"TITLE Removing SVN Folders in %1 && COLOR 9A && FOR /r \"%1\" %%f IN (.svn _svn) DO RD /s /q \"%%f\" \""

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
While working, an annoying popup showing below will come and we cannot cancel or close it form the screen. The error message will come again and again.
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now