[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Automate script to delete folders in Windows Vista

Posted on 2011-03-10
5
Medium Priority
?
385 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 59

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 2000 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 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Assume you have an outside contractor who comes in seasonally or once a week to do some work in your office, but you only want to give him access to the programs and files he needs and keep all other documents and programs private. Can you do this o…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
Suggested Courses
Course of the Month17 days, 15 hours left to enroll

829 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