Ask coding questions

← Back to all posts
How do you delete multiple files?
rcwhiteley

I have to delete each file individually, by clicking on the three dots, then pressing delete.

Every time I do a new tutorial, I create a new file, but now my repl is a mess.

Voters
Qaimaq
kofflermarlon
SongBroker
kencuke
AlexE11
Szron
DavidEdmonds
kellystudent
aniaker
JuhwanKim
Comments
hotnewtop
Anteemony

I mostly use python and I use the os module in this kind of situations on repl. Especially when I'm working in the root folder. Here's an example code

import os

cwd = os.getcwd()
test = os.listdir(cwd)

for item in test:
if item.endswith(".mp3"):
os.remove(os.path.join(cwd, item))

Paradoxian

I put them all in the same folder and then deleted it.

Still took forever, but at least it was faster.

AlexE11

Would be nice! You can use the shell pretty easily too though, so very happy they have that there!

HosseinHakimzad

I agree, this is a big problem. I created a program to extract images from a video every so many seconds. Unfortunately I ran it in the background for a while while answering email and now I have hundred of files to delete manually. If there is no solution, I may have to write a program to delete them!