I'm looking for an elegant way to remove all files in a folder that have the extension .jpg
I have the following to count the total jpg files in a folder:
Option(new File(path).list).map(_.filter(_.endsWith(".jpg")).size).getOrElse(0)
Thanks in advance, any help much appreciated :)
for {
files <- Option(new File(path).listFiles)
file <- files if file.getName.endsWith(".jpg")
} file.delete()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With