Searching sub directories by file type & size (SOLVED)

Hi guys

I have a movie directory in my NAS containing over 130 folders each folder contains the movie file along with some other files such as .jpg’s .nfo’s etc and every folder contains a file called folder.jpg and I want to locate one of them, the problem is I only have the file size to go on

I don’t really fancy the prospect of opening each folder individually and checking the filesize of each folder.jpg file so my question is is there a command I can run that will list all these folder.jpg files along with their file size so I can identify the one I’m looking for

I tried to cd into the directory and running ls & ls -l but that only lists the sub directories and the man page doesn’t show anything that might do it

Any help would be much appreciated


You could try:
cd in to base directory where all other sub directories reside.

find . -name "folder.jpg" -size 1024k

The . represents current directory where find runs ‘file’ on every file in or below of this directory.
You could specify the full path here if you do not fancy cd ing in.
Set size accordingly

'c' for bytes 'k' for Kilobytes (units of 1024 bytes) 'M' for Megabytes (units of 1048576 bytes)

+1 What SeZo said … or install gnome-search-tool and use its GUI (Accessories > Search for Files…)

Hi SeZo

Thanks for your help, I tried your command but probably got it wrong somehow, the file size I’m looking for is 342.09kb here’s the output

graeme@Linux1 ~ $ cd /mnt/NAS/movies/Childrens
graeme@Linux1 /mnt/NAS/movies/Childrens $ find . -name "folder.jpg" -size 1024k
graeme@Linux1 /mnt/NAS/movies/Childrens $ find . -name "folder.jpg" -size 342.09k
find: Invalid argument `342.09k' to -size
graeme@Linux1 /mnt/NAS/movies/Childrens $ find . -name "folder.jpg" -size 342k
graeme@Linux1 /mnt/NAS/movies/Childrens $ 

I’ll try the search tool Mark suggested meantime and post back with the result, I wasn’t aware there was such a tool

Many thanks



find . -name "folder.jpg" -size -343k

This will locate files with sizes less than that value
Or you could try to supply both upper and lower values:

find . -name "folder.jpg" -size +342k -size -343k

File sizes aren’t always accurate (or translate perfectly from the CLI to the GUI) and “usually” are lower in the CLI so maybe try

find /mnt/NAS/movies/Childrens/ -name "folder.jpg" -size +320k -size -344k -exec ls -lh {} \;

Be Aware - that also applies to the gnome-search-tool as it’s really just a GUI for the “find” command, so bear that in mind when defining the “size at least” and “size at most” parameters.

Thanks guys

I found the file using the search tool, I set the search criteria between 340kb-350kb and only 1 file was found and it turned out to the file I was looking for

Once again many thanks for your help