Windows batch find and delete?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/code-flow.club/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
25 views
find /some/path -type d -name .svn -delete
find /some/path -type d -name "Prefix_*" -delete
find /some/path -type f -name "*.bak" -delete



Need analog, but for Windows.


For files *.bak is working the following (found on the Internet, but do not quite understand how it works, for /? the information gives a little)
for /R "D:\\SomePath" %X in (*.bak) do (del "%X")



But for directories does not work.
by | 25 views

6 Answers

0 like 0 dislike
find /some/path -type d -name .svn -delete
for /D /R "D:\\SomePath" %X in (svn) do (rmdir /S /Q "%X")
\r
find /some/path -type d -name "Prefix_*" -delete
for /D /R "D:\\SomePath" %X in (Prefix_*) do (rmdir /S /Q "%X")
\r
From the documentation [1] for
Directories only
\r
If the set contains wild cards (* and ?), the specified command executes for each directory (instead of a set of files in a specified directory) that matches set. The syntax is:
\r
for /D {%% | %}variable in (set) do command [CommandLineOptions]
\r
[1] technet.microsoft.com/en-us/library/bb490909.aspx
by
0 like 0 dislike
find.exe from gnuwin32 ?
by
0 like 0 dislike
actually windows has built-in find, but it is more simplified grep for similar. Maybe it will be enough for the puzzles, there are more experienced win-friends should have a go.
Can you power shell to try? Well or to deliver cygwin and to use the usual Linux commands and scripts.
by
0 like 0 dislike
for files del *.bak /s /q
by
0 like 0 dislike
by
0 like 0 dislike
And there is such a thing called cygwin — I suggest you look.
Personally, I would implement the task on WSH (Jscript/VBscript) — there is a language much more powerful, so you want available through the collection Enumerator.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Aug 12, 2019 by Vladislav123321123
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
110,608 questions
257,186 answers
0 comments
23,588 users