I have many files in my external harddrive, so I want to automatically tell the computer to sort all my files into folders, by their size, extension, name and other variables. Is there any program that will allow me to perform these tasks. Please teach me how to install it too.

  • How can you use the script to perform such tasks.
    – owl
    Commented Nov 8, 2012 at 10:44

3 Answers 3


If you're OK to use bash commands, you should look the man page for the find command Manpage icon.

find . -name \*.txt -size +599k -exec mv {} bigTextFolder \;

With this line, you can move all .txt files bigger or equal than 600KB into the bigTextFolder folder. You can find a lot of documentation about find on the net (Beginner Linux Guide) and the list of all tests available in the man page (first link).

To understand the command, look arguments:

  • . is the directory where find will look for file. You can replace that by the path of your HDD.
  • -name \*.txt is the name filter. It can use wildcards(*) if you escape them with . You can read this like "Find all the file with a name ended by .txt". Replace that by the pattern you're looking for:
    • All file beginning by a: find . -name a\*
    • The file aba.txt: find . -name aba.txt
  • -size +599k is the size filter. Here you say "Find all the file with a size strictly superior too 599KB". Change 599 to the size you want, and k is just the unit.
  • -exec allows to execute another command once a file is found. So here, for each file found, we do mv fileFounded targetFolder. The {} will be replace by your result. This part has to end with \;.

Keep in mind that you have a lot of other filters: type, date, owner, permissions,...

  • I need something more specific, I don't quite understand the commands, sorry for the trouble. I am new to linux.
    – owl
    Commented Nov 8, 2012 at 11:29
  • Did that work ? Please let us know if you've got any problem.
    – NorTicUs
    Commented Nov 9, 2012 at 9:44
  • Yeah, I think it should. However, I don't quite understand it, so I might need a video demonstration, to get it clear.
    – owl
    Commented Nov 9, 2012 at 12:48

I am not aware of some readily available program for it, but you can write a shell script by combining commands like

du -a | sort -nr

will display files in reverse order of size.

and you can use it in combination with NorTicUs's script mentioned in post above

find . -name \*.txt -size +599k -exec mv {} bigTextFolder \;

to specify dynamic size by replacing 599K with variable holding output of 1st command.


I'm making a Python script that sort files by their extensions. In the future it will have more features but I think that this can help you https://github.com/phaalonso/FileOrganizer


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .