Solved

Automate script to delete folders in Windows Vista

Posted on 2011-03-10
5
367 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 51

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

One of the features I've come to appreciate about Windows 7 and Windows Server 2008 R2 is the ability to pin applications to the task bar. As useful a feature as I've found this, it does have some quirks.  For example, have you ever tried pinning an…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.

757 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

21 Experts available now in Live!

Get 1:1 Help Now