Skip to content
← Back to Community
How do you delete multiple files?
Profile icon
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
Profile icon
faceyacc
Profile icon
Mufaddall
Profile icon
ThomasBoogaerts
Profile icon
LMChiang
Profile icon
NoahCodes
Profile icon
Qaimaq
Profile icon
kofflermarlon
Profile icon
SongBroker
Profile icon
kencuke
Profile icon
AlexE11
Comments
hotnewtop
Profile icon
lokeshkaloni

i am facing the same problem can u help

Profile icon
GaneshJadhav

Save the below content in a python file ---- run.py

Run the command on shell ------- python run.py

import os
directory = os.getcwd()

for filename in os.scandir(directory):
if filename.is_file():
os.remove(filename)

Profile icon
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))

Profile icon
Paradoxian

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

Still took forever, but at least it was faster.

Profile icon
SathvikTheCoder

@Paradoxian No need you can just drag the file and drop in the folder with is done in 1 min :D

Profile icon
AlexE11

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

Profile icon
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!