Solved

Automate script to delete folders in Windows Vista

Posted on 2011-03-10
5
370 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 53

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no backā€¦
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.

839 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