B
B
burdakovd2010-10-26 21:03:32
cmd/bat
burdakovd, 2010-10-26 21:03:32

Windows batch find and delete?

find /some/path -type d -name .svn -delete<br/>
find /some/path -type d -name &quot;Prefix_*&quot; -delete<br/>
find /some/path -type f -name &quot;*.bak&quot; -delete<br/>

We need an analogue, but for Windows.
For *.bak files, the following works (I found it on the Internet, but I don’t quite understand how it works, for /?it gives little information)
for /R &quot;D:\SomePath&quot; %X in (*.bak) do (del &quot;%X&quot;)

But it doesn't work for directories.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
U
umcherrel, 2010-10-26
@burdakovd

find /some/path -type d -name .svn -delete
for /D /R "D:\SomePath" %X in (svn) do (rmdir /Q /S "%X")
find /some/path -type d -name "Prefix_*" -delete
for /D /R "D:\SomePath" %X in (Prefix_*) do (rmdir /Q /S "%X")
From the documentation [1] on for
Directories only
If set contains wildcards (* and ?), the specified command executes for each directory (instead of a set of files in a specified directory) that matches set. The syntax is:
for /D {%% | %}variable in (set) do command [CommandLineOptions]
[1] technet.microsoft.com/en-us/library/bb490909.aspx

S
Sergey, 2010-10-26
@bondbig

in general, windows has a built-in find, but it looks more like a simplified grep. Maybe it will be enough for the task, here more experienced win-comrades should suggest.
Can you try power shell? Well, or install cygwin and use the usual Linux commands and scripts.

M
max_rip, 2010-10-26
@max_rip

for files del *.bak /q /s

M
max_rip, 2010-10-26
@max_rip

but for svn forum.script-coding.info/viewtopic.php?pid=19558#p19558

E
Evgeny Sementsov, 2010-10-27
@relsy

And there is also such a thing called cygwin - I advise you to take a closer look.
Personally, I would implement the task in WSH (Jscript / VBscript) - the language is much more powerful there, incl. you want to be available through the Enumerator collection.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question