Delete 1000 various files from a folder in 1 go

Status
Not open for further replies.

Sponge Bob

Active Member
3,153
2009
192
0
Hello,

Does anyone have a method to delete a given 1000 file names, from a specific folder at one go?

is it possible via SSH or even if a script that can do that.

Please share.

Thanks
 
20 comments
For listing that need files
find /your/folder/location -name '*.html' -exec ls -l {} \;


For removing that files
find /your/folder/location -name '*.html' -exec rm -f {} \;


First list them see if you are getting correct ones then delete them with second command, there are other lots of ways like

List file names
grep -rl "match" /folder/location
Delete them
grep -rl "match" /folder/location | xargs rm



Hope it helps
 
please explain more or give an example

like these are my file names just an example

234234234.jpg
4534543543.jpg
54746564.jpg
5464756475645645.jpg
24f43r43r534f34.jpg

something like that what would the .sh be and how do i run it
 
open the content in notepad and save with anyfilename.sh

add like this

rm 234234234.jpg
rm 4534543543.jpg
rm 54746564.jpg
rm 5464756475645645.jpg
rm 24f43r43r534f34.jpg

login to ssh & run the filename in your linux box .

sh filename.sh

sh is shell script
 
put : "rm -f" in front of all those files with a text replacement software, ie notepad++ and put ";" semicolon after each file path, then paste everything in your PuTTy window, this shall remove all files.

But im still sure, there a batch style way to do it, you will have to do a little research.
 
Status
Not open for further replies.
Back
Top