Viktor Apoyan
Viktor Apoyan

Reputation: 10755

Delete some files using batch files

I must create batch file to delete files of a directory which names first symbols are "a". How can I do it?

Upvotes: 0

Views: 8257

Answers (2)

Marco
Marco

Reputation: 57573

If you're using Windows try this (assuming *full_path* is directory you want to delete in):

@echo off
DEL /Q full_path\a*.*

or if you want to delete files from that dir and in its subdir, try this:

@echo ff
DEL /Q /S full_path\a*.*

If you're using Linux (or similar), try this:

rm -f full_path/a*

or

rm -rf full_path/a*

Upvotes: 5

flob
flob

Reputation: 3908

If you are using something like Linux or OSX or Cygwin try

find . -name "a*" -delete

If you want to remove whole directories

find . -name  "a*" | xargs -n 5 rm -r

Upvotes: 0

Related Questions