Smallest File Finder

Joined
Apr 9, 2014
Messages
15
Reaction score
0
Points
1
I am new to mac, I am trying to build a app which can display the smallest file in the system. Tell me some ideas how to do it?
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Moved to more appropriate forum.

Can you be a little more specific? Are you looking for all files or only files from a certain location on the filesystem? What language are you using?
 

pigoo3

Well-known member
Staff member
Admin
Joined
May 20, 2008
Messages
44,213
Reaction score
1,424
Points
113
Location
U.S.
Your Mac's Specs
2017 15" MBP, 16gig ram, 1TB SSD, OS 10.15

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
You can leverage the command line for this one. Try adapting this to your needs.
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,765
Reaction score
2,106
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
It's fairly simple..
Code:
In psuedo code:

Create data structure to hold
      size
      name
      directory

Open a directory
     Create instance of data structure and initialize to empty/NULL
     Get first entry
     Is it a directory?
          Recursively call yourself
     Is it a file?
          Determine the size of the file
          Is the data structure empty?
                Save all information of file in data structure
                Go to next file
          Compare size of this file to data structure data
          Is this file smaller?
                 Overwrite all information in data structure
                 Go to next file
          Go to next file
Close directory

Now read up on the API and implement..:)
 
OP
F
Joined
Apr 9, 2014
Messages
15
Reaction score
0
Points
1
Moved to more appropriate forum.

Can you be a little more specific? Are you looking for all files or only files from a certain location on the filesystem? What language are you using?

reply: i am using objective-c language and trying to find smallest file in complete file system.
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Raz0rEdge's psuedocode ought to get you started. This might also help.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top