Click here to Skip to main content
13,201,763 members (70,547 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

8.2K views
3 bookmarked
Posted 19 Mar 2011

Deleting some directories recursively (i.e. .svn folders when you start a new project)

, 19 Mar 2011
Rate this:
Please Sign up or sign in to vote.
How to delete all the .svn folders using a simple batch file
You are doing a new project and you want to use the old files there. Moreover you have everything under Subversion. In that case, if the old files have a lot of folders it can be a nightmare to delete all the .svn files one by one.

Using this mini-script will do the trick with only two clicks (or a return ^^) without installing any software... so if you are under some strict policies, then it can help you.

Let's hope that some of you will find it useful! I've found it on the Internet and thought it would be really interesting to share it here... more after reading some problems with Subversion.

Here it goes, the line you've to execute:

FOR /F "tokens=*" %%G IN ('DIR /B /AD /S *.svn*') DO RMDIR /S /Q "%%G"


You can see the full post at this link[^], where the author (vanillabean) has posted these explanations:

FOR /F "tokens=*" %%G IN ('DIR /B /AD /S *.svn*') DO RMDIR /S /Q %%G

If you're thinking WTF?:
DIR /B /AD /S *.svn*
lists all files that are named .svn
/B makes the output "bare" with nothing but the file name
/AD only lists directories
/S recurses subdirectories to include their contents if they match the listing criteria

RMDIR /S /Q [path/name]

deletes the directory [path/dir] and all of it's children

FOR /F processes each item (in this case directories) in the set IN ('[command]') by executing the DO [command]

%%G is a parameter, which in this example is a directory name
"tokens=*" says that all the characters output in a line (i.e. by the dir command) are assigned to the parameter %%G


Hope this helps. :thumbsup:

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Joan M
Chief Technology Officer robotecnik
Spain Spain
I'm from Catalonia (in Spain) and a specialist in CNC, PLC, robotics and automation in general.

From 1998 I've been developing software applications for the automation market.

I'm using different technologies in each case to get the proper result, fieldbus communications, special electronics, special laser sensors, artificial vision, robot arms, CNC applications, PLC's...

www.robotecnik.com[^] - robots, CNC and PLC programming

You may also be interested in...

Pro
Pro

Comments and Discussions

 
Generalnice Pin
CIDev13-Apr-11 7:08
memberCIDev13-Apr-11 7:08 
A handy little tip.
Just because the code works, it doesn't mean that it is good code.

GeneralRe: nice Pin
Joan M18-Feb-17 0:03
professionalJoan M18-Feb-17 0:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171020.1 | Last Updated 20 Mar 2011
Article Copyright 2011 by Joan M
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid