LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-05-2020, 02:25 PM   #1
motherboard
LQ Newbie
 
Registered: Jun 2018
Posts: 12

Rep: Reputation: Disabled
How to delete small files?


I have thumbnail jpgs mixed with wallpaper jpgs. How do I delete all files below 100kb?
 
Old 03-05-2020, 02:25 PM   #2
descendant_command
Senior Member
 
Registered: Mar 2012
Posts: 1,876

Rep: Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643
man find
 
Old 03-05-2020, 02:40 PM   #3
uteck
Senior Member
 
Registered: Oct 2003
Location: Elgin,IL,USA
Distribution: Ubuntu based stuff for the most part
Posts: 1,177

Rep: Reputation: 501Reputation: 501Reputation: 501Reputation: 501Reputation: 501Reputation: 501
Seems like a good project to learn some shell scripting.
 
Old 03-05-2020, 02:53 PM   #4
bazio101
Member
 
Registered: Feb 2020
Location: Greece
Distribution: Slackware
Posts: 32

Rep: Reputation: 15
How to delete small files?

You can use something like this to find all jpgs smaller than 100K

find <photo_dir> -type f -name "*.jpg" -size -100k -exec ls -l {} \;

If you are happy with the result, change "ls -l" with "rm"

Last edited by bazio101; 03-05-2020 at 03:05 PM.
 
1 members found this post helpful.
Old 03-05-2020, 03:10 PM   #5
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
this works
Code:
7cf856101ea88be665e51b77ac0ed2f7.png  ffb7f69e4f8d4fd1b02c0881ae0ff933.png
7d0fa3aeb06af7e792adcebc4641a540.png  ffbbc32d5074f1f5e45674d3512ce0dc.png
7d0fa6ca5f2eb8d8cf18acf2dd5afeda.png  ffcee17575f45ccd219e9f1bd1d9aa45.png
7d194efc25199a640b3625d07b80f68e.png  ffdbdd4d4fed89d979bbb9f42e513093.png
7d1b79de7b36cd7c3e16b90ad7344014.png  ffe9ec67c2aff457d84d962f22cf110d.png
userx@slacky.mac:~
$ find .cache/thumbnails/normal -type f -name "*.png" -size -100k -delete
userx@slacky.mac:~
$ ls .cache/thumbnails/normal
userx@slacky.mac:~
 
Old 03-07-2020, 04:41 AM   #6
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by bazio101 View Post
You can use something like this to find all jpgs smaller than 100K

find <photo_dir> -type f -name "*.jpg" -size -100k -exec ls -l {} \;

If you are happy with the result, change "ls -l" with "rm"
And once again, somebody gave OP the handout they were asking for, enabling yet another "code fisher".

BTW, find also has a -delete option.
 
Old 03-07-2020, 08:19 AM   #7
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by ondoho View Post
And once again, somebody gave OP the handout they were asking for, enabling yet another "code fisher".

BTW, find also has a -delete option.
post #5

where is the sin in telling someone how to do something?
 
Old 03-07-2020, 01:46 PM   #8
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,738

Rep: Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222
Quote:
Originally Posted by ondoho View Post
And once again, somebody gave OP the handout they were asking for, enabling yet another "code fisher".

BTW, find also has a -delete option.
find also has a -ls option, which produces a long listing.
 
Old 03-08-2020, 10:47 AM   #9
GPGAgent
Senior Member
 
Registered: Oct 2018
Location: Surrey UK
Distribution: Mint 20 xfce 64bit
Posts: 1,026
Blog Entries: 3

Rep: Reputation: 133Reputation: 133
Or if you prefer use file manager, sort by size and just select all files below 100kb then right-mouse and delete.
 
Old 03-09-2020, 01:19 AM   #10
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
^ If they're all in 1 dir, if the system in question has a GUI, then I'd also do it like that
 
Old 03-09-2020, 09:29 AM   #11
GPGAgent
Senior Member
 
Registered: Oct 2018
Location: Surrey UK
Distribution: Mint 20 xfce 64bit
Posts: 1,026
Blog Entries: 3

Rep: Reputation: 133Reputation: 133
^ Good point! Or you could use Catfish - see attached image - all png files with those less then 100kb selected - now they could be deleted quite easily.
Attached Thumbnails
Click image for larger version

Name:	catfish.png
Views:	15
Size:	45.3 KB
ID:	32749  
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
need to rsync only selected files (--files-from) also need to delete files on dest. ? BrianK Linux - General 5 10-22-2009 09:52 PM
Can I delete files in /mnt/tmp? and Files in the trash can will not delete? M$ISBS Slackware 15 10-02-2009 11:56 PM
How to delete files that won't delete? di11rod Linux - Security 7 10-19-2005 09:14 PM
Openldap with small directory very small iholdap Linux - Networking 5 10-04-2003 08:09 AM
3 small problems in 1 small post vzzt! Linux - Software 10 02-27-2003 07:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration